What you need to do is if (action>=1 || action<=7){/*...*/}else{/*...*/}
The else block executes only if the expression evaluates to zero.
When you need to check that the value is one of a list, there's quite a few things you can do, but the simplest is if (value==something || value==some_other_thing || value==some_other_other_thing)
You should take some time to study the difference between &&, ||, !, &, |, ~, and ^, and their precedences. It will come in handy at one point or another.
I tried the 'if(action!=1||action!=2||action!=3 ect...)' line but it doesn't work, if you input something other then 1-7 it still executes code till you get to the if. EDIT: for example if you input 'asf' it just skips and goes to the next statement.
I would use breaks as well, but if I don't have a line to execute something if the user inputs something other then 1-7 then there's no point in sticking a break in anywhere.
switch ( action )
{
case 1 :
case 2 :
case 3 :
case 4 :
case 5 :
case 6 :
case 7 :
{
//Your code for conditions 1-7
break; // dont forget this
}
default :
{
// code for any other exception
break;
}
}
my syntax is correct,
double check your code, make sure you are using ':' not ';'
if it make you feel better then just forget the '{}'s :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
switch ( action )
{
case 1 :
case 2 :
case 3 :
case 4 :
case 5 :
case 6 :
case 7 :
//Your code for conditions 1-7
break; // dont forget this
default :
// code for any other exception
break;
}
int lose;
int action;
int action2;
int action3;
int action4;
int action5;
int A = 1;
int B = 2;
int C = 3;
int D = 4;
int E = 5;
int F = 6;
int G = 7;
long exit;
cout << "Welcome to TUS, your objective is to defeat the forum guardians at the sub-section gates, let the rape begin ...\n";
cout << "\n";
cout << "Username login: ";
cin >> user;
cout << "Enter Password: ";
cin >> pass;
cout << "\n";
cout << "Welcome to the forums " << user << ".\n";
cout << "Please input the corresponding forum number .. \n\n";
cout << ":: +1+ Site Wank ::\n:: +2+ Metal Gear Shit ::\n:: +3+ Metal Gear Shit II ::\n:: +4+ Movies and Shit ::\n:: +5+ Other Games ::\n:: +6+ General Shit ::\n:: +7+ Spam Board ::\n";
cout << "\n";
cin >> action;
switch ( action )
{
case 1 :
case 2 :
case 3 :
case 4 :
case 5 :
case 6 :
case 7 :
cout << "+1+ Begin flaming FULL FORCE\n+2+ Try to reason with it\n+3+ Fat Joke\n+4+ Ignore it and just dump buckets of cum down it's ass\n";
cout << "\n";
cout << "Input number corresponding to action: \n";
break;
default:
{
cout << "Please enter the correct number dipshit!!\n";
cout << "Type 'exit' and hit return to exit\n";
cin >> lose;
return 0;
}
if (action2 == 4)
{
cout << "\n";
cout << "You try bitterly to ignore the massive TUS Admin infront of you..\nIt doesn't seem to be working much .....\n\nYou grab a bucket of cum and do the obvious\n\nHe begins to tell you something about Castlevania 3 but you don't care and continue on ..\n\n";
cout << "\n";
cout << "You continue your browsing through the forums .. \n";
cout << "\n";
cout << "Browsing the threads in forum no." << action;
cout << "\n";
cout << "\n";
cout << "All of a sudden a robot rumbles into view\n";
cout << "It looks like that robot from the movie 'WALL-E'\n";
cout << "... but it has 'WALLEYE' sprayed on the side of it instead ..\n";