0 votes 0 votes // C program to illustrate sizes of // pointer of array #include<stdio.h> int main() { int arr[] = { 3, 5, 6, 7, 9 }; int *p = arr; printf("p = %p\n", p); printf("*p = %d\n", *p); printf("sizeof(p) = %lu\n", sizeof(p)); return 0; } Sourav_35 asked Jun 7, 2018 Sourav_35 654 views answer comment Share Follow See all 2 Comments See all 2 2 Comments reply Sourav_35 commented Jun 7, 2018 reply Follow Share The output shows sizeof(p)=8.But how? Since p is a pointer to array shouldn't it be 4 bytes? 0 votes 0 votes Naveen Kumar 3 commented Jun 9, 2018 reply Follow Share I didn't get why printf("p = %p\n", p); <--this instruction not produced any output?? I checked output is as: *p=3 // since, printf("*p = %d\n", *p); sizeof(p) = 8 //since, printf("sizeof(p) = %lu\n", sizeof(p)); 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes Answer: p = address of pointer p. (%p is used to print the address of pointer) *p = 3 (it is the value at address which is stored in p) or (the data pointed by pointer p) sizeof(p) = 8 (because it is the size of address stored in p. it is not the size of array) address stored in p is of 8 bytes in 64 bit address stored in p is of 4 bytes in 32 bit dmchaudhary answered Jun 10, 2018 dmchaudhary comment Share Follow See all 0 reply Please log in or register to add a comment.