Click to See Complete Forum and Search --> : what happens when case has no content


ireland
December 15th, 2005, 06:17 AM
what happens in the following case


switch(somechar)
{
...
....
case '=' :
case 'D' ://do something
break;
}


will case 'D" also be entered when the character is "=" ??

Marc G
December 15th, 2005, 06:23 AM
Yes.

NMTop40
December 15th, 2005, 06:31 AM
It enters the next case because there is no "break" at the end of it, not because it has no content.

switch ( x )
{
case 1:
func1();
case 2:
func2();
};

if x is 1 it will do func1() and func2(), if x is 2 it will do only func2().

ireland
December 15th, 2005, 07:00 AM
thanks folks.