Consider the below program.
Pretty Simple program.. huh… Output will be 0.
Now if you replace arr with 0[arr], the output would be same. Because compiler converts the array operation in pointers before accessing the array elements.
e.g. arr would be *(arr + 0) and therefore 0[arr] would be *(0 + arr) and you know that both *(arr + 0) and *(0 + arr) are same.
Please write comments if you find anything incorrect in the above article.
- Pointer to an Array | Array Pointer
- Double Pointer (Pointer to Pointer) in C
- Pointers in C and C++ | Set 1 (Introduction, Arithmetic and Array)
- Dangling, Void , Null and Wild Pointers
- NULL pointer in C
- What are near, far and huge pointers?
- Function Pointer in C
- void pointer in C
- Memory Layout of C Programs
- C function to Swap strings
- Storage for Strings in C
- Pointer vs Array in C
- Why C treats array parameters as pointers?
- How to declare a pointer to a function?
- Output of the program | Dereference, Reference, Dereference, Reference....