switch statement using char

May 4, 2013 at 2:35am
My question is why does this not work??? I am getting error messages:
"In function `int main()':"
"case label `'m'' not within a switch statement"
"break statement not within loop or switch" and on and on.... Please explain???

//using the switch statement

#include <iostream>


using namespace std;
int main ()

{
string name ;
char letter ;
cout << "Please enter a character (m,t,s):" ;
cin >> letter;
switch (letter)
cout << name;
case 'm':
name = "Mary" ;
break;
case 't': name = "Thomas" ;
break;
case 's': name = "Susan";
break;
default: name = "Nobody" ;
cout<<name <<endl;

system("PAUSE");
return EXIT_SUCCESS;
}
May 4, 2013 at 2:56am
Try switch(letter){} you forgot brackets
May 4, 2013 at 3:58pm
I did! Thank you giblit!!!
Topic archived. No new replies allowed.