C - Operators - Discussion

You Are Here :: Home > C > Operators - Discussion

 



Q.

Find the output :

main()
{
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));
}

A. 11 B. 12
C. 22 D. 42

Answer: Option B
Explaination:

 


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.



Discussion

Your Comments Goes here...
NameDiscussion