653 views
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;

}

1 Answer

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

 

 

Related questions

0 votes
0 votes
0 answers
1
shiva0 asked Jan 11, 2019
624 views
#include int main() { int i = 1; printf("%d %d %d\n", i++, i++, i); return 0; }
1 votes
1 votes
1 answer
4