binary files

Hi guys,
I'm feeling confused on random access binary files.

When creating a random access binary files, do I have to convert everything into a const char* to write it to the file?

Thanks in advance
The answer is yes

Every character must be a char to print it or write it to the binary file.
What about storing whole structures or even more complex structures?
How do you think its done?
It musn't be a const char,but you must know the size/location within the file of the data you want to read.
Actually for binary files, write byte by byte to the file in binary write mode is the safest. All you got to do is to make sure e.g 1st to 4th byte contain A, 5th to 10th byte contain B etc etc. Then the contents in each of the byte will be hexadecimal format say 0x00 to 0xFF.

All these details implies we need to have some standard serialization mechanism and according to posters in this forum, they say C++ Boost library has this serialization class which we can use. I have not tried out Boost so I cannot comment but it is worth a look.
Topic archived. No new replies allowed.