Skip to content

Instantly share code, notes, and snippets.

@iamleeg
Created March 27, 2012 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 iamleeg/2214389 to your computer and use it in GitHub Desktop.
Save iamleeg/2214389 to your computer and use it in GitHub Desktop.
Nested C array
int main(int argc, char *argv[]) {
int x[5][5][5];
int i, j, k;
for (i = 0; i < 5; i++) {
for (j = 0; j < 5; j++) {
for (k = 0; k < 5; k++) {
x[i][j][k] = k + 5 * j + (5*5*i);
}
}
}
printf("x: %d\n", x);
printf("x[1]: %d\n", x[1]);
printf("x[1][1]: %d\n", x[1][1]);
printf("x[1][1][1]: %d\n", x[1][1][1]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment