Puzzle P15

parameter p pointing to local variable a in main

Contents of a Pointer

Does the following code compile? If so, what does it write to the monitor?

#include <stdio.h>

void newFunction( int *p )  
{
  printf("  p=%d\n", p ); /* Note: no * before p */
}

void main ( void )
{
  int a = 77 ;
  printf("a=%d\n", a ) ;
  newFunction( &a ) ;
}

It looks like printf(" p=%d\n", p ) gets the contents of p and prints it. But what is that?



Previous Page        Answer         Next Page         Home