C Pointer Size

If p is declared as char *p then what is size of(*P)?

Showing Answers 1 - 36 of 36 Answers

jeyaraj

  • Sep 29th, 2011
 

(Note: If both the p and P specified in the code are same then)

It prints the Size of the Value of pointer and not the Size of the pointer.

And the value it prints is always '1'

  Was this answer useful?  Yes

amitabha

  • Oct 7th, 2011
 

char *p ....it holds the address of a character.. so a address always is a integer.. hence the answer is 2.

  Was this answer useful?  Yes

visweswararao

  • Oct 27th, 2011
 

here char *p p is a pointer not *p is a pointer
the sizeof(*p) is 1 byte
the sizeof(p) is 2 byte because it is a pointer so it always takes 2 bytes of memory

surendrap

  • Nov 16th, 2011
 

the sizeof(*p) will be 1 because here p is a pointer variable of type char . and size of char is 1.

i.e. sizeof(*p)= 1.

  Was this answer useful?  Yes

neha

  • Nov 20th, 2011
 

size of p is machine dependent in this case

  Was this answer useful?  Yes

pavitra

  • Dec 3rd, 2011
 

The pointer will be independent upon data type.
so it will be take 2 bytes for any data type

  Was this answer useful?  Yes

yogita.

  • Jan 3rd, 2012
 

The size of p is 4 bytes,actually it depends on the compiler on which you run this code,if compiler is 32 bit pointer is 4 bytes if compiler is 16 bit pointer size is 2 byte.The size of *p is 1 byte as it holds the value of a character.

Code
  1. void main()

  2. {

  3.   char *p;

  4.   char x = 1;

  5.   p = &x;

  6.  

  7.   printf("The size of pointer p is %d

  8. ", sizeof(p));

  9.   printf("The size of *p is %d

  10. ",sizeof(*p));

  11. }

  12.  

  13.  

  Was this answer useful?  Yes

Divya

  • Jan 10th, 2012
 

Array[0]

  Was this answer useful?  Yes

vaishali

  • Feb 28th, 2012
 

Size of *p is 1 byte, as it is character pointer.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions