include<iostream.h>
char roll;
int main()
{
cout<<"Yahtzee\n";
while (roll != 'Y' && roll != 'N')
{
cout<<"Roll? (Y/N)\n";
cin>>roll;
}
system("PAUSE");
}
It outputs:
Yahtzee
Roll? (Y/N)
If i type in anything that is longer than one character, "Roll? (Y/N)" will appear the same number of times as the length of what i entered in.
Why does this happen and is there a better way to go about this?
char roll;
int main()
{
cout<<"Yahtzee\n";
while (roll != 'Y' && roll != 'N')
{
cout<<"Roll? (Y/N)\n";
cin>>roll;
}
system("PAUSE");
}
It outputs:
Yahtzee
Roll? (Y/N)
If i type in anything that is longer than one character, "Roll? (Y/N)" will appear the same number of times as the length of what i entered in.
Why does this happen and is there a better way to go about this?