help with switch

Sep 25, 2013 at 3:00pm
Please help
i can't enter restart and test what do i need to do --thanks in advance.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 void main(){
char test,restart;
do{
cout<<"enter test"<<endl;
cin>>test;
switch(test){
case 'test':
cout<<"This is a test \n"; 
break;
defualt:
cout<<"You did not enter test try again";
break;
}
cout<<"Enter restart"<<endl;
cin>>restart;
}while(restart=='restart')
}
Sep 25, 2013 at 3:12pm
First my friend you can't store a string value in a char variable;
for example you can assign
char someChar='a';
or
char someChar='r';

string word="restart";
string name="Homer Simpson";

Second try with a boolean type
for example:

bool repeat=true;
do{

//clever code
//more
//more

cout<<"Want to restart? (0 exit 1 restart) ";
cin>>repeat;
}while(repeat);

Last edited on Sep 25, 2013 at 3:13pm
Sep 25, 2013 at 3:42pm
main() must return int, so change the type void with int.
Sep 25, 2013 at 4:36pm
You really don't need a break; at the end of the switch statement after the default:
Topic archived. No new replies allowed.