Skip to content

Instantly share code, notes, and snippets.

@neanias
Created October 22, 2015 12:31
Show Gist options
  • Select an option

  • Save neanias/3e3f6382e47b25ff0ceb to your computer and use it in GitHub Desktop.

Select an option

Save neanias/3e3f6382e47b25ff0ceb to your computer and use it in GitHub Desktop.
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