decalring large arrays

Dave Harris Dave.Harris at f14.n15.z1.fidonet.org
Fri Jun 21 15:11:36 AEST 1991


In a message of <Jun 18 20:32>, Rickey Thomas Tom (1:114/15) writes: 
 >I have a simple question. I sort some data. The easiest way to do this is 
 >to 
 >decalre a large array to sotre this data and then sort the array. 
 >However,
 >it apopears that in a DOS environment, I am only allowed an array up to 
 >64 K in size. Is there a way to declare larger arrays than this for sort. 
 >Is there another way that I could store a large quantity of data for 
 >sorting.

 >Any comments would be appreciated. Thanks in advance.

Some of the Dos implementations allow for the huge modifier which will allow 
for larger arrays.  After 128K though you are stuck with powers of 2, ie 256K 
and 512K (should you be that lucky) are the only other legal sizes as near as 
I can gather.

Assuming that your array isn't just raw integers but rather a struct of size 
say 20 or larger, then allocate these, have an array of pointers pointing to 
the allocated memory spots, and sort the array containing the pointers.

Assuming you don't need much more than 64K, you can hold 2 64K arrays with 
data, qsort each 64K block then merge/shuffle sort the 2 blocks.

 


 

--  
Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!15!14!Dave.Harris
Internet: Dave.Harris at f14.n15.z1.fidonet.org



More information about the Comp.lang.c mailing list