why is getline not allowed here and also whey is the else statement not supposed to be and where do i put the break if i want it to exit the loop if they answer correct
#include<string>
#include<iostream>
usingnamespace std;
void game(void);
int SecretNumber = 3;
int Counter = 0;
string Correct = "You guessed my Number!!";
string Incorrect = "You guessed wrong try again";
void game(int guess, string Correct, string Incorrect)
{
do
{
cout << "I'm thinking of a number between 1 and 10 guess till you get it correct";
getline(cin, guess);
cin.ignore(999, '\n');
if (!cin.fail());
cin.clear();
cin.ignore(999, '\n');
cout << "You need to enter a. Try again.";
}
while (guess != SecretNumber);
++Counter && cout << Incorrect << "You have guessed" << Counter << "times";
else
cout << Correct;
break;
}
int main(void)
{
game();
cin.ignore(999, '\n');
cout << "Press ENTER to finish...";
return 0;
}