bool help with arrays?!

I want a function that will take a text string as a parameter (so we can actually use it to ask a variety of yes/no questions), and will return a true if they answer yes, false if they answer no. A possible implementation is provided, using an array of characters as a parameter to hold the text string.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  bool keepGoing(const char q[])
{
   char cmd;
   do {
      // display the question and get their answer
      printf("%s", q);
      scanf(" %c", &cmd);
      cmd = toupper(cmd);
      if (cmd == 'Y') {
         return true;
      } else if (cmd != 'N') {
         printf("Invalid command entered, please try again\n");
      }
   } while ((cmd != 'Y') && (cmd != 'N'));
   return false;
}


now in my programs parameter i have : bool keepGoing(const char q[]);
under my main i have my function as the code above... but when i compile it, it gives me an error in the last bracket saying:

expected 'while' at end of input
expected '(' at end of input
expected primary-expression at end of input
expected ')' at end of input
expected ';' at end of input
expected '}' at end of input

any ideas?
Looks fine to me, include your entire program if possible.
Topic archived. No new replies allowed.