Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
C++ declaration error
#1
Hello (C++) programmers of southperry. I'm having a really simple problem with this code that I can't figure out.

Code:
int main()
{
srand(time(NULL));
int upperBound = 100;
int lowerBound = 1;
int range = upperBound - lowerBound;
int guess = 1 + rand() % range;
char playersRespond;
cin >> playersRespond;

do {
    if (playersRespond == '1') {
      //do something;
    } else if (playersRespond == '2') {
      //do something;
    } else {
    cout << "Please type in 1, 2 or 3" << endl;
    }
  } while (playersRespond != 3);

char c;
cin >> c;
return 0;
}

My compiler says I have a "declaration error" at the line:

} while (playersRespond != 3);

I have no idea what I'm doing wrong.

edit: does it have something to do with me saying "while (playersRespond != 3)" when i already have an "else" statement within the "do"?
Reply


Messages In This Thread
C++ declaration error - by sky54264 - 2009-09-15, 12:35 PM
C++ declaration error - by Tempus - 2009-09-15, 12:56 PM
C++ declaration error - by Fiel - 2009-09-15, 01:02 PM
C++ declaration error - by sky54264 - 2009-09-15, 01:04 PM
C++ declaration error - by Tempus - 2009-09-15, 02:56 PM
C++ declaration error - by Fiel - 2009-09-15, 08:13 PM
C++ declaration error - by Takebacker - 2009-09-15, 08:35 PM
C++ declaration error - by Russt - 2009-09-15, 08:52 PM
C++ declaration error - by sky54264 - 2009-09-15, 08:56 PM
C++ declaration error - by Russt - 2009-09-15, 09:07 PM
C++ declaration error - by Fiel - 2009-09-15, 09:19 PM
C++ declaration error - by Russt - 2009-09-15, 10:15 PM
C++ declaration error - by sky54264 - 2009-09-15, 11:08 PM
C++ declaration error - by Russt - 2009-09-15, 11:35 PM
C++ declaration error - by Fiel - 2009-09-16, 09:30 AM
C++ declaration error - by sky54264 - 2009-09-16, 07:23 PM
C++ declaration error - by Russt - 2009-09-18, 08:22 PM
C++ declaration error - by Fiel - 2009-09-19, 05:05 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)