I have a requirement to pad out some data in a binary file with the null charactor '\0' added every second or thrid charactor. Try as I may I cannot prevent the app from ignoring the null charactor.
I have tryed various castings and conversions without any luck.
pseudo code below shows what I have right now.
Code:string data = "J\0O\0H\0N\0"; ofstream File; file.open("c:\\somefile.dat", ios_base::binary | ios_base::in | ios_base::out); file.write(data.c_str, sizeof data)
Only the first char 'J' makes it to the file followed by some junk equal to the sizeof data - the first char.