I'm just writing some quick number guessing game code, but I keep running into the "Expected Unqualified id" error.
I've checked all the semicolons, but maybe I've missed something?
Here's my code:
#include <iostream>
#include <stdlib.h> // srand
using std::cout;
using std::endl;
using std::cin;
int main(void) {
/* code goes here */
srand (time(NULL));
int number = rand() % 100+1;
int guess = 0;
cout << number << endl; /* debug */
do {
/* code goes here */
cout << "Guess a number between 1 and 100: ";
cin >> guess;
if ( guess > number ) { cout << "Too high, try again. \n" << endl;}
else if ( guess < number ) { cout << "Too low, try again. \n" << endl; }
else { cout << "That's right! \n" << endl; }
exit(0);
} // fi
while ((number));! std:: = guess);
return (0); }
// main }`
and here's the error text:
ERROR!
/tmp/3NFruHJf2U.cpp: In function 'int main()':
/tmp/3NFruHJf2U.cpp:27:27: error: expected unqualified-id before '=' token
27 | while ((number));! std:: = guess);
| ^
Probably you want to use:
while(number != guess);
and remove exit(0)