PDA

Click to See Complete Forum and Search --> : loading from file.../...Padding Ints


wossname
Jul 3rd, 2001, 01:39 PM
I know I've asked this question in another thread, but I feel it warrants its own thread.

I have an array of objects (in theory at this stage) and each of these objects is a group of 16 unsigned long ints.

I do not know how namy elements there will be in this array when the program starts, but it will be only just enough to hold the complete contents of a file (filename specified by the user).

So how do I read the contents of this file into this array? The file can be of any length between 0 and 2 megabytes, and may therefore be a few bytes short of a multiple of 16 bytes.

For example if the file is 10 bytes long, I will only need one element in the array and i'll have to pad the rest of the int group with zeros.

Also, if the file stops short of filling one of the integers, how do I pad the remainder of that int and all the following ints with zeros?

(((Oh god I wish VB had unsigned long ints!)))

Zaei
Jul 3rd, 2001, 11:44 PM
Use a pointer (ah, such wonderful things). "ptr = new unsigned int[numInFile];"

Z.