1

I tried the below c code.

void checkPointers () {
  int a[10];
  int *p = a;
  printf("\n the value of p is \t %p \n",p);
  printf(" the location of p is \t %p \n", &p);
  printf(" the value of a is \t %p \n",a);
  printf(" the location of a is\t %p \n", &a);
}

The result it showed me was this..

 the value of p is       0x7ffd6a7ce1b0 
 the location of p is    0x7ffd6a7ce1a8 
 the value of a is       0x7ffd6a7ce1b0 
 the location of a is    0x7ffd6a7ce1b0 

The output shows different value and location for p which is expected but in case of array variable a it shows the value and location as same. Is there any special case for array variables that I am not aware of?

Siddhant Swami
  • 323
  • 1
  • 3
  • 14

0 Answers0