// Illustration of limits of array size, cost of even simple op on large array.
#include <stdlib.h>
#include <stdio.h>
int main(){
	int i, j; 

#if 1 // array too large

	int n = 100000; 
	int b[n][n];
	for (i = 0; i < n; ++i)
	    for (j = 0; j < n; ++j)
			b[i][j] = 0;

#else // try one tenth as big and use heap too.

	int n = 100000;
	int m =  10000;
	short *b = malloc(n*m*sizeof(short));
	if (b == NULL) { printf("allocation failure\n"); return (-1); }

	for (i = 0; i < n; ++i)
	    for (j = 0; j < m; ++j)
			b[i*m + j] = i*m+j; //b[i][j] = 0;

	printf("%d\n", b[rand()%n*m + rand()%m]);

#endif
}
