From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/language%2Fcontinue.html | 61 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 devdocs/c/language%2Fcontinue.html (limited to 'devdocs/c/language%2Fcontinue.html') diff --git a/devdocs/c/language%2Fcontinue.html b/devdocs/c/language%2Fcontinue.html new file mode 100644 index 00000000..831fd254 --- /dev/null +++ b/devdocs/c/language%2Fcontinue.html @@ -0,0 +1,61 @@ +

continue statement

Causes the remaining portion of the enclosing for, while or do-while loop body to be skipped.

+

Used when it is otherwise awkward to ignore the remaining portion of the loop using conditional statements.

+

Syntax

+ +
attr-spec-seq(optional) continue ;
+ +
attr-spec-seq - (C23)optional list of attributes, applied to the continue statement

Explanation

The continue statement causes a jump, as if by goto, to the end of the loop body (it may only appear within the loop body of for, while, and do-while loops).

+

For while loop, it acts as

+
while (/* ... */) {
+   // ... 
+   continue; // acts as goto contin;
+   // ... 
+   contin:;
+}

For do-while loop, it acts as:

+
do {
+    // ... 
+    continue; // acts as goto contin;
+    // ... 
+    contin:;
+} while (/* ... */);

For for loop, it acts as:

+
for (/* ... */) {
+    // ... 
+    continue; // acts as goto contin;
+    // ... 
+    contin:;
+}

Keywords

continue

+

Example

#include <stdio.h>
+ 
+int main(void) 
+{
+    for (int i = 0; i < 10; i++) {
+        if (i != 5) continue;
+        printf("%d ", i);             // this statement is skipped each time i != 5
+    }
+ 
+    printf("\n");
+ 
+    for (int j = 0; j < 2; j++) {
+        for (int k = 0; k < 5; k++) { // only this loop is affected by continue
+            if (k == 3) continue;
+            printf("%d%d ", j, k);    // this statement is skipped each time k == 3
+        }
+    }
+}

Output:

+
5
+00 01 02 04 10 11 12 14

References

See also

+
C++ documentation for continue statement
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/language/continue +

+
-- cgit v1.2.3