Skip to content

Instantly share code, notes, and snippets.

@Miqueas
Last active October 5, 2025 02:20
Show Gist options
  • Select an option

  • Save Miqueas/4e5a37528d085340ff36b028a94120ce to your computer and use it in GitHub Desktop.

Select an option

Save Miqueas/4e5a37528d085340ff36b028a94120ce to your computer and use it in GitHub Desktop.
[C] Cursed or interesting?
#include <stdio.h>
int main(void) {
// So apparently arrays in C are just pointers, which means
// they basically points to the address of the first element
// and when we index them using the `[]` syntax, we're just
// performing an addition on that address and the syntax
// itself doesn't seem to matter that much either.
int arr[4] = { 2, 4, 6, 8 };
// This will print the first element (2)
printf("*arr: %d\n", *arr);
// This will print the second element (4)
printf("1[arr]: %d\n", 1[arr]);
// This will print the third element (6)
printf("*(arr + 2): %d\n", *(arr + 2));
// Of course, you can also use that syntax to iterate over
// arrays too
for (int i = 0; i < 4; i++) {
printf("index: %d - value: %d\n", i, i[arr]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment