For some reason, my write-to-textfile function suddenly stopped working.
void write_data(char* filename, char* writethis) { ofstream myfile; myfile.open (filename, std::ios_base::app); myfile << endl << writethis; myfile.close(); }
The function is called from a loop, so basically it started with an empty line and added all the following βwritethisβ lines to a new line.
Then all of a sudden, no more new lines. All text has been added on one line. So I did digging, and I came across this:
- Windows = CR LF
- Linux = LF
- MAC <0SX = CR
So, I changed the line to
myfile << "\r\n" << writethis;
And it worked again. But now I'm embarrassed. I encode linux , but I read text files created using the program on Windows after transferring them using filezilla . Now, what part of this caused lines to appear in a text file as one line?
I was sure that "endl" worked fine for linux, so now I think the windows messed up the file after with the file files? By waving how the text file is written (and read), I guarantee that my program will break, so if anyone can explain this, I will be grateful.
I also donβt remember what I changed in my program to make it break, because before it worked perfectly. The only thing I added is threading.
Edit: I tried to transfer the transfer mode from ASCII / Binary (even removed the force-ASCII-for-txt extension), but it makes no difference. New lines appear in linux, but not in windows. 
How strange.