Wednesday, 4 January 2012

Placement Question-4

What is the output of the following program ?


char *p;

printf("%d %d ",sizeof(*p),sizeof(p));


1 2
The sizeof() operator gives the number of bytes taken by its
operand. P is a character pointer, which needs one byte for storing its value (a
character). Hence sizeof(*p) gives a value of 1. Since it needs two bytes to store
the address of the character pointer sizeof(p) gives 2.

No comments:

Post a Comment

host gator coupon