I've been learning C++ for about a year now, and it's the first lower-level language I've learned. Anyway, here's my problem:
I have a program with a loop in it. Inside this loop is a integer. It looks something like this:
Code:
#include <iostream.h>
#include <string.h>
int main()
{
int x = 0;
while (x == 0)
{
char question[80];
cin >> question;
cout << "\nWould you like to play again? (Y/N): ";
char yorn[10];
char y[] = "y";
char n[] = "n";
cin >> yorn;
x = strcmp(yorn, y);
}
return 0;
}
Now, for some reason, when the user enters two words with a space in between them in the "question" entry, the program ignores the loop. So then I tried this:
Code:
#include <iostream.h>
#include <string.h>
int main()
{
int x = 0;
while (x == 0)
{
char question[80];
cin.get(question, 79);
ect...
That works, but then when you run the program again, the program ignores the
Code:
cin.get(question, 79);
. What is causing this? is there any way to clear the data out of