thank you guys for the reply and it works. im having difficulties understanding why it needs this kind of code cin.ignore(10000,'\n')? is this common problem when calling a function with a string? thanks again.
The buffer contains some data, and at the end of that data is a newline character.
cin>>choice;
User enters 1 and presses ENTER, buffer looks like this:
<1> <NEWLINE>
The <1> is taken out. Buffer looks like this:
<NEWLINE>
getline(cin,str1);
getline reads from the buffer as far as <NEWLINE>. Where is the <NEWLINE>? At the front of the buffer. So getline reads nothing, and the program carries on.
cin.ignore fetches characters from the buffer and throws them away. You need to throw away that <NEWLINE> at the front of the buffer.
std::cin.ignore(10000,'\n'); means "throw away characters from the buffer until you've thrown away 10000, or until you've thrown away a NEWLINE.
std::cin.ignore(std::numeric_limits<std::streamsize>::max()); means "throw away characters from the buffer until you've thrown away some really big number of them.