This is a very commom error for beginners.
The reason is that you're mixing input methods.
The stream extractors stop reading when they find a whitespace -> leaving the final '\n' in the bufferCode:cin>>size;
getline stops reading when it finds the terminating character ( by default '\n' ) that's why an empty string is returned.Code:string name; cout<<"Insert the name of the person you wanna terminate"<<endl; getline(cin,name);
solution: put
after the use of the stream extractor.Code:cin.ignore();
Kurt




Reply With Quote
