0
How will I properly run my swtch case?
I am having problems compiling it. it usually says that it expects a ";" before a ":". Help me fix the error please.
6 Respuestas
+ 3
you should also use break; statement after every case
+ 2
Try this
switch (l)
{
case 'M':
cout<<"string of text"<<endl;
case 'F':
cout<<"another string of text" <<endl;
case 'm':
cout<<"string of text"<<endl;
case 'f':
cout<<"another string of text" <<endl;
default:
cout<<"my default case";
cin>>l;
}
+ 1
must be using unnecessary colon or semicolon......send the switch case code you wrote
0
switch (l)
{
case 'M','m':
cout<<\*string of text*\<<endl;
case 'F','f':
cout<<\*another string of text*\ <<endl;
default:
cout<<\*my default case*\;
cin>>l;
}
0
First.
You can't separate conditions by a comma. You can write as
case 'M': case 'm':
Second.
for comments these are wrong slash..... use normal slash(/) rather than backward slash(\)
Third.
In the cout line the compiler skips the comments after correction so the compiler may read it as
cout<< <<endl; which will display an error as there is no need for two <<....
0
I just did the comments for my strings. So I need to do it like a case per char?