Scope and Massive arrays
I am writing a piece of code which has a 256 element long int array (long int SmallerArray) which it reads from a file (this part works) and then creates an array of the above arrays of a size which is dependent on the file it reads. So it reads through the file twice, once looking for the total number of arrays, once to take the actual data into the arrays. So eventually it's sort of like this:
long int *MassiveArray[totalNumArrays]
where each element in MassiveArray is a pointer to an SmallerArray. I need MassiveArray to be global, but I don't know the 'totalNumArrays' number until after I go through a function. Is there any way to define an array without actually saying how big it is?
BTW, I can't stick a maximum value on MassiveArray like doing MassiveArray and then just using however much of it I need - it needs to be scalable according to the file's specifications.
dynamic memory management with new and delete should do the trick for you, assuming you have enough RAM memory available. Look up dynamic memory/new and delete operators for arrays in your favorite textbook, tutorial, or bulletin board (hint: this ain't a bad place to start.)