Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Declaring a large array

Status
Not open for further replies.

hed

MIS
Mar 26, 2001
3
US
I'm using Borland C++ and I can't declare an array larger than 10,000 bytes (type 'char'). I need about 30k, would someone please tell me how to do it, I forgot to say that this is for a DOS program. Shoulden't it be possable to somehow put the data in it's own segment and get 64k (65,536)?
 
I would try to use the calloc function instead of a array Declaration and use of a far pointer.

Perhaps you have to select the correct memory model.

hnd
hasso55@yahoo.com

 
use files instead of memory allocating. John Fill
1c.bmp


ivfmd@mail.md
 
Unless you are using some sort of memory management like Phar Lap's, you can't put an array on it's own segment. You're stuck with whatever is left over in the base memory w/ DOS. Your choices are to use one of the above or something like vector in STL.

James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
i'm presuming you're getting the "array size too large error".

unfortunately dos has limitations on this because it is only 16 bits, you can get larger arrays using malloc() or calloc() ie:

char * x = (char*)malloc(unsigned int);

but you're still limited to a 2byte unsigned integer maximum of 65,535 index values. however, it IS possible to go beyond this, it's just not as straight-forward to index it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top