Bizarre problem with goto and do/while loop

This is an extract from my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 Test:
    cout<<endl;
	cout<<" Enter the Host Team : "<<endl;
	cin.getline(a,29);
	cout<<" Enter the Away Team : "<<endl;
	cin.getline(b,29);

....

 cout<<endl;
    cout<<"       Do You Want To Simulate Another Game?  <Y/N>"<<endl;   
    cin>>ans;
    if(ans=='y' || ans=='Y')
    {
                system("CLS");
                goto Test;
                
    }                                  


    system("PAUSE");
    return 0;
}


Well, when the program starts it works normally, but when it reaches the end and asks me whether i want to simulate again, it does the clear screen, it does go to Test, it does print the text "Input the host team", but it skips the first cin.getline!
Afterwards, it just prints the second line "Input the Away Team :" and waits for the second cin.getline input.
I've never had this kind of a problem before.
NOTE: I tried the same thing with a do/while loop instead of a goto function, it makes the same problem again. (a and b are chars, if that can help somehow)
It's reading the newline from when you type "Y" and press ENTER.
You need to read in the newline and ignore it.
Topic archived. No new replies allowed.