Skip to main content
gamedev.net
🔒 Locked

C++ char() / fstream problem

Started by makerm2 May 1, 2004 at 2:56 PM 1 replies 550+ views
Original Post
makerm2
makerm2
I''m having a problem, which can be easily summed up by, in outputting [by fstream] a char(10), it outputs BOTH a char(13) and then a char(10) [carriage return, etc...]... although for the program I''m making i NEED it to ONLY output a char(10)... is there an option to turn that extra char off? if not, is there any other way to output to a file char(10) only? thanks... source code that sums up problem: #include <iostream> #include <fstream> using namespace std; int main(){ ofstream ofile("C:\\test.x"); ofile << char(10); ofile.close(); cout << "done \n"; return 0; }
SiCrane
SiCrane
Open the file in binary mode. (i.e. pass std::ios_base::binary as the second parameter.)
makerm2
makerm2
works, thanks much ;]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.