if statement with break!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
char step;
std::cout"Enter y for yes, n for n, proceed for p"<<endl;
std::cin>>step;
if (step=='y')
{
std::cout <<"YES"<<endl;
}
else if (step=='n')
{
std::cout <<"NO"<<endl;
}
else if (step=='p')
{
std::cout <<"PROCEED"<<endl;
}
else
{
//cin.clear();
//std::cout<<"You entered wrong character please try again;
//cin>>step;
break;
}
|
It doesn't work for me, what is the problem, any help!
The above code doesn't work,
You need << after cout on line 2.
break; is only used to break out of loops or switch statements. If your code is not inside a loop or a switch it doesn't make sense to use break;.
The break statement can be used only in an iteration statement (loop) or a switch statement. I see neither of these in your code.
Okey thank your very much guys, It helps a lot.
Great!
Topic archived. No new replies allowed.