Whenever i try to run this code :
string title;
int Choice;
cout<<"1. Insert new term ";
cin>>Choice;
if (Choice==1)
{
getline(cin,title);
}
the program only read the Choice and end the whole process :/ , help please :D
cin>>Choice;
leaves the trailing newline character in the input buffer. Andgetline(cin,title);
therfore reads an empty line.In general, it's better not to mix formatted input with
getline
from the same stream.A quick and easy fix is to remove the trailing newline character from the stream using
std::basic_istream::ignore
, like so: