Cannot figure out this Error

I know this is stupid.. im trying to get a switch statement to work.. for learning purposes.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <string>
using namespace std;

int main()
{
   string name1;
   cout<<"Enter a name: "<<endl;

   cin>>name1;

   switch(name1){

   case 'Brian':
   case 'brian':

   cout<<"Brian Kiani"<<endl;

   break;

   defualt:
   break;

}

    return 0;
}


1
2
3
4
5
6
7
||In function `int main()':|
|12|error: switch quantity not an integer|
|14|warning: multi-character character constant|
|15|warning: multi-character character constant|

||=== Build finished: 1 errors, 2 warnings ===|
 


Why am I getting the error and the 2 warnings?
Last edited on
You can only use a an integer variable for a switch statement. Also, between two single quotes, there has to be a single character (escape sequences such as '\n' are exceptions).
Finally, it's default, not defualt.
1) you cannot use a switch for non-integral types
2) you are using multi-char literals, not string literal
3) you spelled default incorrectly
4) http://www.cplusplus.com/doc/tutorial/control/#switch
ok..
Topic archived. No new replies allowed.