New to C++, writing first script, need help finding bug
First off, please don't hate on me I know I'm a total noob! I keep getting an error when I try to compile this and I can't seem to find out why. I'm reviewing the book I purchased to help me, but I still can't find out whats going wrong. I know its something small and dumb.. Can ANYONE help :)
If you could please point out what needs to be corrected and why, it would be extremely helpful to me. Thank you so much in advance.
Code:
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int secret_number, guess, count;
cout << "Let's play a guessing game!" << endl << endl;
cout << "I'll pick a number from 0 to 9, inclusive." << endl;
cout << "Good luck!" << endl << endl;
secret_number = rand() % 10;
count = 0;
do {
if (count)
cout << "Sorry, that's not it!" << endl;
cout << "enter your guess: ";
cin >> guess;
{ while ( guess != secret_number ) && ( ++count <= 9 ) );
if ( guess == secret_number )
{
cout << "You got it in " << count << "guesses!" < endl;
cout << "Good work!" << endl;
}
else
{
cout << "Sorry, you used up all your guesses!" << endl;
cout << "The secret number was: " << secret_number << endl;
cout << "Better luck next time!" << endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}