Turbo C large character array

Walter Bright bright at Data-IO.COM
Tue Jul 31 04:17:56 AEST 1990


In article <1990Jul27.193520.4689 at ux1.cso.uiuc.edu> gordon at osiris.cso.uiuc.edu (John Gordon) writes:
<	I am trying to declare a char array that is rather large, and TCC
<won't accept it, it says it is too large to fit within available memory.
<		char menu[1200][80];
<	By my calculations, this shoud be equal to 96K worth.  I am using
<the Huge model, which specifically says that arrays of more than 64K may be
<used.

The huge model is not necessary. Try rewriting it as:
	char *menu[1200];
Initialize as:
	for (i = 0; i < 1200; i++)
		menu[i] = (char *) malloc(80);
Use as:
	menu[i][j]

Look, ma, no huge pointers! I also think you'll find that this executes
faster than huge model, because no pointer normalization is necessary.

For space efficiency, you might also consider reversing the array indices.



More information about the Comp.lang.c mailing list