Hi, I've written the following code just to check and it's behaving strange. It prints the string one step later... Please let me know what's wrong in it:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int t, x, n, i;
string s;
cin >> t;
for(x = 1; x <= t; x++)
{
cin >> n;
getline(cin, s); // eat the '\n'
for(i = 0; i < n; i++)
{
getline(cin, s);
cout << s << endl;
}
}
return 0;
}
Thanks in advance
and sorry if there is already a post related to this, I failed to find out 
I've also tried using cin.ignore(1,'\n'); but it don't work as well.