1 2 3 4 5 6 7 8 9 10

void reset (int* y) {

*y = 5;

/* put 5 in cell pointed to by y */

}

int i = 3, j = 3;
initialize ( i );
reset ( &j );
printf ( "%d, %d", i, j );

This will print 3, 5, since we have passed a pointer to j into the function, the value pointed at is changed by the reset - note that the invocation reset (j)will cause all sorts of problems, since the parameter j isn't a pointer.

*

When would j be a pointer?
intj[10];
then
reset (j);is the same as reset ( &j[0] ); thus the parameter j is a pointer. HOWEVER, the
corresponding formal parameter would still be
void reset ( int* y );

January 22, 1999

Page 6

copyright UoA