So this is a pretty simple question, I just can't find info on reading in a string which has a space using getline. The syntax I've tried for my program is
getline(cin, mystring, '\n'), but that doesn't seem to work. The program just ignores the rest of what is supposed to be inputted and exits.
1 2 3 4 5 6 7 8 9 10 11
void Individual_Entry::set_name()
{
string name_entry;
cin.ignore();
cout << "Please enter the name: ";
getline(cin, name_entry, '\n');
this->name = name_entry;
}
My bad, edited it down to the function. I need to know why my program is going haywire if I try to enter two separate names of a full name in one line when getline should be working. The program works fine with a singular name.
remove the newline character from getline() else it's left in the input stream:
Explicit delimiting character: The operation of extracting successive characters stops as soon as the next character to extract compares equal to this.