Puzzle P18

two functions with pointer parameters

Of course, a function can be called several times, with different arguments. What does the following write to the monitor?

#include <stdio.h>

void aFunction( int *p )  
{
  *p = 99; 
}

void main ( void )
{
  int a = 44, b = 77 ;
  printf("a=%d  b=%d\n", a, b ) ;

  aFunction( &a ) ;
  printf("a=%d  b=%d\n", a, b ) ;

  aFunction( &b ) ;
  printf("a=%d  b=%d\n", a, b ) ;
}

In the first call, the parameter of aFunction() points to a. In the second call, it points to b.



Previous Page        Answer         Next Page         Home