Skip to content

Instantly share code, notes, and snippets.

@sorindragan
Created November 5, 2017 18:25
Show Gist options
  • Save sorindragan/d6c866eb8434986b78eb444873d48cc0 to your computer and use it in GitHub Desktop.
Save sorindragan/d6c866eb8434986b78eb444873d48cc0 to your computer and use it in GitHub Desktop.
3D matrix in C with memory allocation
int main() {
grid = (int***)malloc(num_players * sizeof(int**));
for (int i = 0; i < num_players; i++) {
grid[i] = (int**)calloc(num_lines, sizeof(int*));
for (int j = 0; j < num_lines; j++) {
grid[i][j] = (int*)calloc(num_cols, sizeof(int));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment