Puzzle P30


Puzzle F30 — difficult

What do you suppose will happen when the following is compiled and run?

#include  <stdio.h> 

void main ( void )
{
  int value;
  int *pv;
  int **ppv;

  value = 32;
  pv = (int *)&ppv;
  ppv = &pv;
  
  printf("value = %d\n", value );
  printf("*pv   = %d\n", *pv );
  printf("**ppv = %d\n", **ppv );

}

This program will compile and run, but is not a sensible thing to do. It might have come about when a programmer, desperate to get a program to compile in spite of an error, put in a type cast which seemed to fix the problem.



Previous Page        Answer         Next Page         Home