2

I came across this problem while taking the online quiz when i tested it in the online ide(Geeks For Geeks) in C language it actually giving the same result but in the test its answer was False.

#include <stdio.h>

int main() {
    int arr[2] = {1,2};
    printf("%d %d",arr,&arr);
    return 0;
}

Output

-1134751264 -1134751264
Neil
  • 21
  • 3

1 Answers1

0

The values of the pointers are the same, but they have different types: a is an int [2] and &a is an int (*)[2].

Other than the type difference, there's only one variation: If you add one to &a, it points to the next array of five ints after a. However, if you add one to a, it points to the next int after *a.

S.S. Anne
  • 15,171
  • 8
  • 38
  • 76