![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Switch + stirng | DNAx86 | Shell Programming and Scripting | 5 | 01-09-2008 07:10 AM |
| switch login | sharif | UNIX for Advanced & Expert Users | 1 | 12-12-2007 01:03 AM |
| switch from csh to ksh | veeracer | Shell Programming and Scripting | 8 | 11-05-2004 11:13 AM |
| switch from csh to ksh | veeracer | UNIX for Dummies Questions & Answers | 1 | 11-03-2004 03:28 PM |
| can you switch | neer45 | Shell Programming and Scripting | 3 | 12-05-2001 05:54 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
Switch
using switch can we match for more than one values..
eg: switcha(a) { case 1, 2, 3: printf("ddd"); break; case 4, 5, 6: printf("mmm"); break; } In this case wat i found was only for the last value, i.e 3 and 6 the switch works. I'd greateful if someone can help me in solving this out(using switch or any other alternative). abey |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
Quote:
Code:
{
case 1:
case 2:
case 3: printf("ddd"); break ;
case 4:
case 5:
case 6: printf("mmm"); break ;
}
vino |
|
#3
|
|||
|
|||
|
thnx, tht works....
is there anyother option to implement this apart from switch, that wil reduce the number of lines. |
|
#4
|
||||
|
||||
|
You can go ahead with the if-else-if combo.
vino |
|
#5
|
|||
|
|||
|
yup, i'l try tht too...
Once again thnx for the help... abey |
|
#6
|
||||
|
||||
|
Quote:
If you have more than two conditions to check for, you are best off using switch. |
|
#7
|
|||
|
|||
|
use if......
if((a==1)||(a==2)||(a==3)) |
|||
| Google The UNIX and Linux Forums |