Help required with getline() function.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;
int main ()
{ 
int t;
cin>>t;
string s;

while(t--)
{
	getline(cin,s);	
} 
return 0;
}


When I try to run this piece of code, It inputs string s t-1 times, while it should take it t times. Can you help me why is this happening?
The firist time around the loop, getline eats the end of line from line 6.
How to make it right? Any suggestions?
Topic archived. No new replies allowed.