Pointer and there sizeof value in c/c++

main()
{
char *a;
printf(“%d%d”,sizeof(*a),sizeof(a));
}

Tutorial answer:1,2

Debugging solution:
Sizeof():it gives no of bytes taken by its operand.
P is character pointer which needs one byte for storing its value.hence
Sizeof(*p)->sizeof(**p)->sizeof(p).result is one1.
Pointer it has two bytes.
So Sizeof(p)->sizeof(*p)->result is 2

Post a Comment

0 Comments