I'm writing a program to read information of a proprietary file format. The format is as follows:
_ The file holds conversation dialogs. So, the main info are strings;
_ The strings are not stored on each row, but one imediately after other, not null terminated. Many integers in the beginning of the file store the string's position and length. So, if you want a certain string, get its position, length and copy a substring from a huge substring.
_ These integers are stored in binary form, so a human cannot read them opening the file in notepad, for instance.
My program shall read these strings and store them in a database. Also, it must read all strings from the database and remake the file from scratch.
I put the entire file into a string and then I slice it and put into the the DB. For that, I read the numerical values this way (dWord = unsigned int):
Now I want to do the opposite way: I have an integer and I want to put it inside a huge string, but it's format shall be binary, so I can write the entire string into a file at once.
Sorry for the poor English. I don't practice it for a while...
Iterate that to write the integer as little endian. If the integer is not signed, the operation will produce wrong results. Look up "endianness" in Wikipedia if you don't know what little endian means.