I want to output a new line into a text file but i dont know how please help
Ex:
jaime adf
new line
This is a discussion on New lines within the C++ Programming forums, part of the General Programming Boards category; I want to output a new line into a text file but i dont know how please help Ex: jaime ...
I want to output a new line into a text file but i dont know how please help
Ex:
jaime adf
new line
Code:#include <fstream> #include <iostream> ... std::ofstream file("MyFile.Txt"); if( file.is_open() ) { file << std::endl; // endl writes a newline character to the file file << '\n'; // This does the same thing file.put('\n'); // Also does the same thing }
I used to be an adventurer like you... then I took an arrow to the knee.
Print this string the way you want:
Note the '\n' char which represents a newline char.Code:"jaime adf\nnew line"