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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maximum Size of char Array

Status
Not open for further replies.

Praetoriansys

Technical User
Apr 14, 2003
2
US
When I use:

char FILE_SIZE[1384446]

I get an error

Whwn I use:

char FILE_SIZE[1000000]

I don't get an error but I can not access my entire file. Is there a way around this? Can I use a different variable type that stores the same as a char?


Thanks
 
Well normally, you would use dynamic memory allocation for such large amounts of memory, say
Code:
char *FILE_SIZE = new char[1000000];
if ( FILE_SIZE != NULL ) {
  // do stuff
}

--
 
The maximum size of your array depends on the amount of bytes that is available in the largest continuous block of memory available to your process.

BUt:
Wouldn't you be better off accessing your file in blocks, if it's that large?


Greetings,
Rick
 
You could map your file into shared memory: then you don't need to allocate anything.
 
LazyMe: Do you consider allocating a couple of megs (on the heap) being all that much today?

/Per

www.perfnurt.se
 
When my PC hard disk makes noises like a washing machine while it takes 5 minuts to find the space and processor time to open a 3K .txt file in notepad, I wish the authors of the 146 different processes and bits and pieces currently making demands on the system HAD considered a couple of megs on the heap as being worthy of notice.
(sorry, just a disgruntled technical user, wishing he could do more technical using and less waiting...)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top