View Single Post
Old May 1st, 2008, 3:21 PM   #12
ChevyCowboy15
Newbie
 
ChevyCowboy15's Avatar
 
Join Date: Nov 2007
Location: Central USA
Posts: 17
Rep Power: 0 ChevyCowboy15 is on a distinguished road
Re: multiple values for one char

I have been messing around some more with the for statement i have a question that has 5 possible answers and do this statement
c++ Syntax (Toggle Plain Text)
  1. cout << "question?\n";
  2. getline(cin,answer1);
  3. for (int i=0; i < 5 ; i++){
  4. if (correct[i]==answer1)
  5. cout << "do something!!\n\n";};
  6. else{
  7. cout << "do something!!\n\n";
  8. break;};

then i compile it with g++ and it brings up with error
k.cpp: In function ‘int main()’:
k.cpp:19: error: expected primary-expression before ‘else’
k.cpp:19: error: expected `;' before ‘else’

i cant figure out where to put or take away the ; ??
ChevyCowboy15 is offline   Reply With Quote