Hey i'm doing a project, and i'm at the part where the user must enter a phrase or sentence and it must be compared to the phrase or sentence already imput to the computer via file. I'm asking a user to enter the sentence / phrase using cin.getline, but when i run the program, with the debugger i see that it is skipping over the cin.getline and just going straight into the next line of code. Why is this?
Here's my code
bool solve(int players, int score[], string phrase, string&
puzzle)
{
bool solved = false;
const int SIZE = 81;
char sentence[SIZE];
int count = 0;
int length;
cout << "You chose to solve the puzzle!" << endl;
cout << "DIRECTIONS: Type in your solution on one line." << endl;
cout << "Separate each word with one space." << endl;
cout << "Solution -> ";
cin.getline(sentence, SIZE);
cout << "Youve have entered: " << sentence << endl;
length = phrase.length();
for (count; count < length; count++)
if (sentence[count] != phrase[count])
{
solved = false;
break;
}
else
solved = true;
if (solved == true)
{
for (count = 0; count < length; count++)
{
puzzle[count] = sentence[count];
}
cout << "You have solved the puzzle!" << endl;
}
else
cout << "That is incorrect, you lose your turn" << endl;
return (solved);
}
Am i doing something wrong? is there a better way to store user imput into an array for this?