The second time it runs through a loop, it screws up.
program looks like this:
main()
{
:
while(Again == 'y' || Again == 'Y')
{
:
:
cin.getline(String1, sizeof(String1));
cin.getline(String2, sizeof(String2));
:
:
:
cout << "Again? (Y/N):";<br>
cin >> Again;
:
}
Now the problem is that every time it gets
to the first cin.getline(), it skips it and
goes to the second cin.getline().
I know that the cin >> statement is messing
it up, but how do i get around this?
Thanx
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
: I got some probs with this program im making...
: The second time it runs through a loop, it screws up.
: program looks like this:
: main()
: {
: :
: while(Again == 'y' || Again == 'Y')
: {
: :
: :
: cin.getline(String1, sizeof(String1));
: cin.getline(String2, sizeof(String2));
: :
: :
: :
: cout << "Again? (Y/N):";<br>
: cin >> Again;
: :
: }
:
: Now the problem is that every time it gets
: to the first cin.getline(), it skips it and
: goes to the second cin.getline().
: I know that the cin >> statement is messing
: it up, but how do i get around this?
:
: Thanx
Do a cin.ignore() before your first cin.getline() statement.
: : I got some probs with this program im making...
: : The second time it runs through a loop, it screws up.
: : program looks like this:
: : main()
: : {
: : :
: : while(Again == 'y' || Again == 'Y')
: : {
: : :
: : :
: : cin.getline(String1, sizeof(String1));
: : cin.getline(String2, sizeof(String2));
: : :
: : :
: : :
: : cout << "Again? (Y/N):";<br>
: : cin >> Again;
: : :
: : }
: :
: : Now the problem is that every time it gets
: : to the first cin.getline(), it skips it and
: : goes to the second cin.getline().
: : I know that the cin >> statement is messing
: : it up, but how do i get around this?
: :
: : Thanx
: Do a cin.ignore() before your first cin.getline() statement.