1.3.4.2 Continue statement
The function of the continue statement is to skip the remaining statements in the loop and enforce the next loop.
The continue statement is used only in a for, while, Do-while, and so on, and is often used in conjunction with an IF condition statement to speed up the loop.
Example 20:
Main ()
{
char c;
while (c!=0x0d)/* is not a carriage return loop * *
{
C=getch ();
if (c==0x1b)
Continue * If press ESC key does not output then carries on the next cycle * *
printf ("%c\n", c);
}
}
1.3.4.3 Goto Statement
A goto statement is an unconditional transfer statement, similar to a goto statement in BASIC. The goto statement is used in the following format:
Goto marking;
Where the label is a valid identifier in Turbo C2.0, this identifier plus a ":" appears in the function somewhere, after the goto statement is executed, the program jumps to the label and executes the subsequent statement. In addition, the label must be in a function with the goto statement, but it may not be in a loop layer. Usually a goto statement is used with an IF condition statement, and when a condition is met, the program jumps to the label to run.
Goto statements are usually not used, mainly because it will make the program level is not clear, and not easy to read, but in the multi-level nesting exit, the goto statement is more reasonable.
Example 19 is time-varying with a goto statement:
Example 21:
Main ()
{
int i=0;
char c;
while (1)
{
C= ' ";
while (c!=13)
{
C=getch ();
if (c==27)
Goto quit;
printf ("%c\n", c);
}
i++;
printf ("The No. Is%d\n ", i);
}
Quit
printf ("the End");
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.