Puzzle P16

calling a function with an int value

Mistake

Let us make a dreadful mistake. This time, intentionally. (Unlike those many unintentional dreadful mistakes.) What is the dreadful mistake? Will the program compile? What will happen when it runs?

#include <stdio.h>

void newFunction( int *p )  
{
  printf("  p=%d\n", *p ); 
}

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

It looks like printf(" p=%d\n", *p ) follows the pointer in p to find a value to print . But what is that?



Previous Page        Answer         Next Page         Home