Today, when I read the code, I found a structure similar to the following:
Switch (error)
{
Case ENUM_0:
Case ENUM_1:
Printf ("case 0 and 1 \ n ");
Case ENUM_2:
Printf ("case 2 \ n ");
Break;
}
If the error value is ENUM_0 or ENUM_1, printf ("case 0 and 1 \ n"); this statement must have been executed. But are you sure you want to go to the following case?
In order to verify this small problem, I wrote an example in VC and tried it. It confirmed that it was actually executed in the branch of case 2. It jumps out only when it reaches break.
[Cpp]
# Include <stdio. h>
Int main (void)
{
Char ch = 0;
Switch (ch)
{
Case 0:
Case 1:
Printf ("case 0 excute \ n ");
Case 2:
Printf ("case 2 excute \ n ");
Break;
}
Return 0;
}
To sum up, the statements under the case Branch will jump out when they are executed until break or return.
From fulinwsuafcie's column