• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Question] Switch

trollebror

Developer
Joined
Aug 8, 2009
Messages
362
Reaction score
58
Location
Sweden, Linköping
I'm a big newbie on C++. This is just a simple rookie question I guess. But how to write two expressions in one switch? Or is there another method to prefer? No high-end solution please! x)

This is the single-expression code:
Code:
switch (n) {
  case 4:
    <code>
    break;
  case 45:
    <code>
    break;
  default:
    <code>
    break;
}

I would like something like this:
Code:
switch (n, n1) {
  case 4, 11:
    <code>
    break;
  case 45, 9:
    <code>
    break;
  default:
    <code>
    break;
}

Thanks in advance.
 
Last edited:
Idk if yuo mean this.

Code:
switch(n)
{
	case 1:
	case 2:
		dupa();
	break;
	case 3:
	case 4:
	case 5:
		costam();
	break;
	case 6:
		xd();
	break;
}
 
Back
Top