I started out by declaring a string and storing all the text entered by the user in it. Then I transfer to a file. I cant figure out how add a line break to the input. I am just a beginner..
example code :
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
string x;
string y;
ofstream a_file("example.txt");
getline ( cin , x);
a_file<<x;
a_file<<y;
}
To add a line break to the output, you need to write the string
"\n"to it.It’s as simple as that. You can also combine the last two statements into one:
But if you want to add the line break to the string, and not only to the file, you can do this: