Hi, it's me again,
Another two problems which I'm having with this example is that when in ofstream constructor I specify mode as binary:
ofstream fout("my_file.txt", ios_base::binary);
nothing is written to a file (at least I can't see there anything)
and another problem which I cannot cross is that I cannot write integers to a file only strings. What I'm doing is:
int a = 1;
fout.write(reinterpret_cast<char*>(&a), sizeof(int));
after this nothing is written in the file;
Hope someone will help me with this kerfuffle.

Recommended Answers

All 2 Replies

Hi There,

I had a sort of similar problem and got some good help. Admittedly I was trying to write an array of floats which needed a pointer but the comments I got gave me some good help on the binary write process, it may help (?)
Check it out here
http://www.daniweb.com/forums/thread204295-2.html
and scroll down to the posts by adatapost. The third page has some useful stuff too.

Ok thanks I'll check it out.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.