I have a binary file containing an unknown number of unions which must be read into a dynamically created array for further processing and sorting.
Can anyone help with the syntax for this????????
This is a discussion on Create Dynamic Array of Unions within the C++ Programming forums, part of the General Programming Boards category; I have a binary file containing an unknown number of unions which must be read into a dynamically created array ...
I have a binary file containing an unknown number of unions which must be read into a dynamically created array for further processing and sorting.
Can anyone help with the syntax for this????????
Well it's like this
http://www.cprogramming.com/cboard/s...threadid=17666
Only you use read() instead of write()
And you open the file for input.
If you want to know how many array elements to allocate, and all the unions in the file are the same size, then just divide the file size by the sizeof() of the union.
Then use the new operator to allocate some memory (see past posts ad-nauseum)