ExamVeda
Login
Home
This question belongs to C Program C Miscellaneous
C Miscellaneous
?

Determine Output:
void main()
{
      char *p;
      printf("%d %d", sizeof(*p), sizeof(p));
}

Answer & Solution
Correct Answer: Option B

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.

Examveda
Question posted by Examveda
Community

Join the Discussion

3 Comments
Bhagvat Giri
Bhagvat Giri 6 years ago
size of pointer is 8 bytes for 64 bit OS
size of pointer is 4 bytes for 32 bit OS
Roshan Meshram
Roshan Meshram 6 years ago
when i executed this code, it gave an output :1 4
Katheeja Beevi
Katheeja Beevi 8 years ago
When I execute the code, I got output as 1 8