Created
October 22, 2015 12:31
-
-
Save neanias/3e3f6382e47b25ff0ceb to your computer and use it in GitHub Desktop.
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
| int n; | |
| int **array; | |
| n = ...; | |
| int i, j; | |
| array = (int **) malloc(n*sizeof(int *)); | |
| // iterate over rows | |
| for (i = 0; i < n; i++) { | |
| array[i] = (int *) malloc(n*sizeof(int)); | |
| for (j = 0; j < i; j++) { | |
| array[i][j] = i; // or *(*(array+i)+j) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment