Hi guys, I just started practicing C++.
Right now I'm trying to put lines of text to a file one by one manually and then stop puting in text by typing end. The thing is that I don't really know how to put the whole line of text one by one into a file and then stop the input by typing a command like "end"...
#include<iostream>
#include<fstream>
using namespace std;
int main()
{
char filename[30];
string sentence;
int i = 2;
cout << "Name your file: ";
cin >> filename;
ofstream outputfile(filename, ios:
ut);
string text;
cout << endl << "Row 1: ";
while (sentence != "end") // <- Lol!
{
cin >> text;
getline(cin, text);
outputfile << sentence << endl;
cout << "Row " << i << ": ";
++i;
}
... more newb code..
return 0;
}
Any sugestions how i can make this possible?
/nunchuckie