![]() |
switch statement
just a quick question about switch statements. is it true that you always have to use break; at the end of each case in a switch statement? Someone was trying to explain a way to me where you don't but every text book i've read says you must.
|
Only if you don't want to execute the next case. That's most of the time.
|
And a short example :
:
int n ; |
just to let you know xavier... that won't do anything since n is not defined :p
now if you did something like this :
int n = 0;it would work |
Quote:
|
I thought you had to use break all the time as well. Im glad you asked that
|
| All times are GMT -5. The time now is 8:09 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC