S
Shawn
Hi,
I need to use break and continue to transfer my program flow. I hope to
use labels to explicitly state where the control flow will be, as
suggested by somebody in the newsgroup. I have noticed something strange:
block1:
{ //compiler doesn't allow "{" here
for (int i = 0; ..)
{
if (conditionSatisfied) continue block1; //this will move control to
the beginning of for loop, for loop will continue to run
} //end of for loop
} //compiler doesn't allow "}" here
block2:
{ //now compiler allows "{" here
...//more code
for (int i = 0; ..)
{
if (conditionSatisfied) break block2; //this will move control to the
end of block2 immediately
}
...//mode code
} //end of block2, break block2 will bring control to the line below
this line
My questions:
1) Why block1 cannot have a pair of {} while block2 can?
2) Is my understanding of the control flow using break or continue
correct in this demo?
Thank you very much.
I need to use break and continue to transfer my program flow. I hope to
use labels to explicitly state where the control flow will be, as
suggested by somebody in the newsgroup. I have noticed something strange:
block1:
{ //compiler doesn't allow "{" here
for (int i = 0; ..)
{
if (conditionSatisfied) continue block1; //this will move control to
the beginning of for loop, for loop will continue to run
} //end of for loop
} //compiler doesn't allow "}" here
block2:
{ //now compiler allows "{" here
...//more code
for (int i = 0; ..)
{
if (conditionSatisfied) break block2; //this will move control to the
end of block2 immediately
}
...//mode code
} //end of block2, break block2 will bring control to the line below
this line
My questions:
1) Why block1 cannot have a pair of {} while block2 can?
2) Is my understanding of the control flow using break or continue
correct in this demo?
Thank you very much.