int main() {
string s1,s2;
cout<<"1. "<<endl;
cin>>s1; //to accept 1st string
cout<<s1<<endl;
cout<<"2. "<<endl;
getline(cin,s2); //to accept 2nd string
cout<<s2<<endl;
}
Here in the above code after accepting the 1st string it is not asking for the 2nd string: the program is getting terminated after taking the 1st input without waiting for the 2nd.
Could anyone kindly explain what the reason of such behavior is? And why is it not waiting for getline(cin,s2)
for taking user input?