I have a problem with the getline
function in the code below. In the "get" info section I want to be able to store a whole sentence, but I can't make it work.
When I open up my program it just skips the input for the info.
p.s: I'm new to C++
Here is the section of the code where i have the problem (Enter the information):
void add() {
string name;
string faction;
string classe;
string race;
string info;
ofstream wowdatabase("wowdatabase.txt", ios::app);
cout << "Add a race or class" << endl;
cout << "---------------------------------------------------------" << endl;
cout << "" << endl;
cout << "Enter the name of the race or class (only small letters!):" << endl;
cin >> name;
cout << "Enter Race (Type -, if writen in name section):" << endl;
cin >> race;
cout << "Enter Class (Type -, if writen in name section):" << endl;
cin >> classe;
cout << "Enter faction (Alliance/Horde):" << endl;
cin >> faction;
cout << "Enter the information:" << endl;
getline(cin, info);
wowdatabase << name << ' ' << faction << ' ' << classe << ' ' << race << ' ' << info << endl;
wowdatabase.close();
system("CLS");
main();
}
Now it works fine =) but, when i want to output the info again it only shows the first word in the sentence?