I want to output a new line into a text file but i dont know how please help
Ex:
jaime adf
new line
Printable View
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
}
Print this string the way you want:
Note the '\n' char which represents a newline char.Code:"jaime adf\nnew line"