For the following code:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--)
{
string s;
getline(cin,s);
cout << s << "\n";
cin.ignore(1000,'\n');
}
return 0;
}
Sample Input:
2
Name1
Name2
Expected output:
Name1
Name2
Error output:
Name2 // followed by blank line
I don't know why is it happening. I tried all the solutions given on stackoverflow but unfortunately none worked for me.Thanks in advance.