Last active
October 14, 2021 04:26
-
-
Save Miqueas/4e5a37528d085340ff36b028a94120ce to your computer and use it in GitHub Desktop.
[C] Cursed or interesting?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* Explanation | |
Arrays in C are just pointers. So, basically they points | |
to the address of the first element and when we indexing | |
using [], we're just performing an addition and the order | |
doesn't matter at all for that operator in C. Also, the | |
array identifier is also the first element itself, as I | |
said, is just a pointer. | |
*/ | |
int main(void) { | |
int arr[4] = { 1, 2, 3, 4 }; | |
printf("*arr: %d\n", *arr); | |
printf("1[arr]: %d\n", 1[arr]); | |
printf("*(arr + 2): %d\n", *(arr + 2)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment