Skip to content

Instantly share code, notes, and snippets.

@fclairamb
Created December 12, 2014 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fclairamb/d5850ef1081353bc9ec5 to your computer and use it in GitHub Desktop.
Save fclairamb/d5850ef1081353bc9ec5 to your computer and use it in GitHub Desktop.
Multi-dimentionnal C array address
#ifdef SHELL
gcc -Wall -Werror $0 && ./a.out
exit $?
#endif
/*
Output:
Table : 0x7fff03ab7490
Row 0 : 0x7fff03ab7490
Cell 0:0 : 0x7fff03ab7490
Cell 0:20 / 1:0 : 0x7fff03ab74e0 == 0x7fff03ab74e0
*/
#include <stdio.h>
int main() {
int tab[20][20] = {};
printf("Table : %p\n", & tab );
printf("Row 0 : %p\n", & tab[0] );
printf("Cell 0:0 : %p\n", & tab[0][0] );
printf("Cell 0:20 / 1:0 : %p == %p\n", & tab[0][20], & tab[1][0]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment