Possible Duplicate:
Need help with getline()
getline not asking for input?
I am working on the following code:
int main()
{
int num;
string str;
cin>>num;
int points[num][2];
for(int i=0;i<num;i++)
{
cout<<"\nPoint"<<i<<":";
getline (cin,str);
points[i][0]=atoi(&str[0]);
points[i][1]=atoi(&str[2]);
}
for(int i=0;i<num;i++)
{
cout<<"\npoint"<<i<<" = "<<points[i][0]<<" "<<points[i][1];
}
The problem with the above code that I am getting is when I enter the num
value as some integer and then press enter, instead of printing...
"Point 0:"
...and waiting for me to enter it prints "Point 0:" and "Point 1:" and then takes the input for Point 1.
For point 0 it automatically takes input as 0 and 0.