Logo 
Search:

C Programming FAQ

Submit Interview FAQ
Home » Interview FAQ » C ProgrammingRSS Feeds

C programming practical question 8

  Shared By: Adah Miller    Date: Jan 24    Category: C Programming    Views: 146

Answer:

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


Answer:
1 2


Explanation:
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.

Share: 
 

Didn't find what you were looking for? Find more on C programming practical question 8 Or get search suggestion and latest updates.


Your Comment
  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].


Tagged: