The person who thinks the C language is still a beginner seems to overestimate himself. I didn't think there was such an interesting thing in this place. Some words seem to be carefully studied to really get started ah ....
================================================================================
Copy Code code as follows:
#include <stdio.h>
int main (void)
{
int flag=0;
for (int j=0 J <2; J + +) {
if (j==0) {
Switch (j) {
Case 0:
Continue
}
flag=1;
}
}
printf ("flag:%d\n", flag);
}
Output:
flag:0
If the code is:
Case 0:break;
Output:
Flag:1
======================================================================
Look again:
Copy Code code as follows:
#include <stdio.h>
void Main ()
{
int flag = 0;
int j = 0;
For (J=0 J <2; J + +) {
if (j==0) {
if (j==0) {
Continue
}
flag=1;
}
}
printf ("flag:%d\n", flag);
}
Output:
flag:0
If the code is:
Break
Output:
flag:0
==========================================
In the C language book, this is the description of continue and break:
The break statement can exit from the inner loop or switch statement.
The continue statement can only appear in the for, while the Do loop
=========================================
Conclusion:The Continue is only valid for the loop body directly containing it (i.e., the for,while, and not the circulation body in switch{}), and the break is the For,while,switch block that directly contains it.
For example, if there is a break or continue in code that does not contain a switch, the break jumps out of the loop, and continue jumps out of the loop.
For code that inserts a switch statement in a loop, the break jumps out of the inner block only, and the block jumps out of the switch only if it is a switch.
and continue even if it appears in the switch block, because the scope of the continue is only for a while and so on loop statements, so it does not work, still out of this cycle.
If you don't pay attention, you'll also think you're jumping out of a switch statement block.