I have this code where the string info is not working as it should.
I have a getline where info is inside and it saves a hole sentence, but it won't output more than the first word.
Example:
"Hello world!"
I will only show me "hello"
Here is the part of the code:
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;
cin.ignore( numeric_limits<streamsize>::max(), '\n' );
cout << "Enter the information:" << endl;
getline(cin, info);
cout << info;
system("pause");
wowdatabase << name << ' ' << faction << ' ' << classe << ' ' << race << ' ' << info << endl;
wowdatabase.close();
system("CLS");
main();
}
void searchname() {
ifstream charecter("wowdatabase.txt");
string name;
string find;
string faction;
string classe;
string race;
string info;
int i = 0;
system("CLS");
cout << "Search for a race or class" << endl;
cout << "---------------------------------------------------------" << endl;
cout << "" << endl;
cout << "Please enter name:";
cin >> find;
while (charecter >> name >> faction >> classe >> race >> info ) {
if (find == name) {
system("CLS");
cout << "Charecter found" << endl;
cout << "---------------------------------------------------------" << endl;
cout << "" << endl;
cout << "Name of race/class: " << name << endl;
cout << "Race: " << race << endl;
cout << "Class: " << classe << endl;
cout << "Faction: " << faction << endl;
cout << "Info: " << info << endl;
cout << "" << endl;
cout << "Press enter to return to menu" << endl;
system("pause");
system("CLS");
main();
}
}