<html>
<body>
Hi Graham,<br><br>
Yes you can. It's probably just a typo in your message, but you have
written the 'case' statements incorrectly. It should be:<br><br>
<font face="Courier New, Courier">switch(a)<br>
{<br>
case 1:<br>
case 2:<br>
do_something();<br>
break;<br><br>
default:<br>
do_anotherthing();<br>
break;<br>
}<br><br>
</font>You should be aware that multiple entry case statements are now
deprecated (isn't that a wonderful word). They should not generate an
error, but may well be non-portable.<br><br>
If you are in doubt about something, the first step is to look at the
listing file and see what the compiler is making of your source.<br><br>
All the best for now,<br>
John<br><br>
<br>
At 14:53 09/03/2007, you wrote:<br><br>
<blockquote type=cite class=cite cite="">If I have a switch statement
with multiple cases like<br><br>
int a;<br>
a=1;<br>
Switch (a)<br>
<x-tab> </x-tab>{<br>
<x-tab> </x-tab>case:1<br>
<x-tab> </x-tab>case:2<br>
<x-tab> </x-tab><x-tab>
</x-tab>
do_something();<br>
<x-tab> </x-tab><x-tab>
</x-tab>break;<br><br>
<x-tab> </x-tab>
default:<br>
<x-tab> </x-tab><x-tab>
</x-tab>break;<br>
<x-tab> </x-tab>}<br><br>
Question:<br>
Does do_something() get executed if a=1 ?<br>
I suspect not but it will if a=2<br>
I want it to execute if a=1 and if a=2<br><br>
If I am correct, how do I get do_something() to execute for a=1 or
a=2<br>
without having separate case: statements ?<br><br>
Can I write case:(1 || 2) ?<br><br>
Sorry for the probably dumb question<br>
I have been writing C code for many years but surprisingly have never
come<br>
across this<br><br>
Graham<br><br>
_______________________________________________<br>
Icc-avr mailing list<br>
Icc-avr@imagecraft.com<br>
<a href="http://dragonsgate.net/mailman/listinfo/icc-avr" eudora="autourl">
http://dragonsgate.net/mailman/listinfo/icc-avr</a></blockquote></body>
</html>