--- id: c-break-continue title: "C Break and Continue" category: "Programming_Language" status: "draft" verification_status: "conceptual" canonical_id: "" aliases: ["break statement", "continue statement", "loop control", "C break continue"] duplicate_of: "" source_trust_level: "B" confidence_score: 0.86 created_at: 2026-07-04 updated_at: 2026-07-04 review_reason: "" merge_history: [] tags: ["c", "programming-language", "w3schools", "loops", "break", "continue"] raw_sources: ["https://www.w3schools.com/c/c_break_continue.php"] applied_in: [] github_commit: "" --- # [[C Break and Continue]] ## ๐ŸŽฏ ํ•œ ์ค„ ํ†ต์ฐฐ (One-line insight) `break` and `continue` are the same two keywords across BOTH switch statements and loops, but their meaning shifts by context โ€” the source explicitly notes `break` was already seen "jumping out" of a `switch` block, and here it does the analogous thing for a LOOP (stop entirely), while `continue` has no switch equivalent at all โ€” meaning `break`'s core behavior ("exit the current block early") generalizes across constructs, but `continue`'s "skip to next iteration" concept is loop-specific. [S1] ## ๐Ÿง  ํ•ต์‹ฌ ๊ฐœ๋… (Core concepts) - **`break`** โ€” stops the loop COMPLETELY, immediately, regardless of remaining iterations. [S1] - **`continue`** โ€” skips the REST of the current iteration's body and jumps straight to the next iteration (does not stop the loop). [S1] - **Combinability** โ€” `break` and `continue` can coexist in the same loop, each triggered by different conditions. [S1] - **Works in both `for` and `while` loops** โ€” the same semantics apply regardless of loop type. [S1] - **Real-world pattern: skip-then-stop** โ€” using `continue` to skip invalid/unwanted values while using `break` to halt entirely on a sentinel value (like a zero marking "end of valid data"). [S1] ## ๐Ÿ“– ์„ธ๋ถ€ ๋‚ด์šฉ (Details) - `break` stopping a for loop at i==4: `for (i = 0; i < 10; i++) { if (i == 4) { break; } printf("%d\n", i); }` โ€” prints 0,1,2,3 then stops entirely. [S1] - `continue` skipping just one value: `for (i = 0; i < 10; i++) { if (i == 4) { continue; } printf("%d\n", i); }` โ€” prints 0,1,2,3,5,6,7,8,9 (skips only 4). [S1] - Combined in one loop: `for (i = 0; i < 6; i++) { if (i == 2) { continue; } if (i == 4) { break; } printf("%d\n", i); }` โ€” prints 0,1,3 then stops at 4. [S1] - Real-life skip-negatives-stop-at-zero pattern: `int myNumbers[] = {3, -1, 7, 0, 9}; for (i = 0; i < length; i++) { if (myNumbers[i] < 0) { continue; } if (myNumbers[i] == 0) { break; } printf("%d\n", myNumbers[i]); }` โ€” prints 3 and 7, skips -1, stops entirely at 0 (never reaching 9). [S1] ## โš–๏ธ ๋ชจ์ˆœ ๋ฐ ์—…๋ฐ์ดํŠธ (Contradictions & updates) - **break์™€ continue์˜ ๊ทผ๋ณธ์  ์ฐจ์ด**: break๋Š” ๋ฃจํ”„๋ฅผ ์™„์ „ํžˆ ์ข…๋ฃŒํ•˜์ง€๋งŒ continue๋Š” ํ˜„์žฌ ํšŒ์ฐจ๋งŒ ๊ฑด๋„ˆ๋›ฐ๊ณ  ๋ฃจํ”„๋Š” ๊ณ„์†๋œ๋‹ค๋Š” ์ ์ด "Good to Remember" ์š”์•ฝ์œผ๋กœ ๋ช…ํ™•ํžˆ ๊ตฌ๋ถ„๋จ. [S1] ## ๐Ÿ› ๏ธ ์ ์šฉ ์‚ฌ๋ก€ (Applied in summary) ์Œ์ˆ˜๋Š” ๊ฑด๋„ˆ๋›ฐ๊ณ (continue) 0์„ ๋งŒ๋‚˜๋ฉด ์™„์ „ํžˆ ๋ฉˆ์ถ”๋Š”(break) ์ˆซ์ž ๋ฆฌ์ŠคํŠธ ์ฒ˜๋ฆฌ ์˜ˆ์ œ๊ฐ€ ์›๋ฌธ์—์„œ ์ง์ ‘ ์‹ค์ „ ํ™œ์šฉ ์‚ฌ๋ก€๋กœ ์ œ์‹œ๋จ. [S1] ## ๐Ÿ’ป ์ฝ”๋“œ ํŒจํ„ด (Code patterns) Combining continue (skip invalid values) and break (stop at a sentinel value) in one loop (C): ```c int myNumbers[] = {3, -1, 7, 0, 9}; int length = sizeof(myNumbers) / sizeof(myNumbers[0]); int i; for (i = 0; i < length; i++) { if (myNumbers[i] < 0) { continue; // skip negative numbers } if (myNumbers[i] == 0) { break; // stop loop when zero is found } printf("%d\n", myNumbers[i]); } ``` ## โœ… ๊ฒ€์ฆ ์ƒํƒœ ๋ฐ ์‹ ๋ขฐ๋„ - **์ƒํƒœ:** draft - **๊ฒ€์ฆ ๋‹จ๊ณ„:** conceptual - **์ถœ์ฒ˜ ์‹ ๋ขฐ๋„:** B (W3Schools โ€” widely used educational reference, not a primary standards body) - **์‹ ๋ขฐ ์ ์ˆ˜:** 0.86 - **์ค‘๋ณต ๊ฒ€์‚ฌ ๊ฒฐ๊ณผ:** ์‹ ๊ทœ ์ƒ์„ฑ (New discovery) ## ๐Ÿ”— ์ง€์‹ ๊ทธ๋ž˜ํ”„ (Knowledge Graph) - **์ƒ์œ„/๋ฃจํŠธ:** [[C Tutorial]] - **๊ด€๋ จ ๊ฐœ๋…:** [[C For Loop RealLife]], [[C Switch]], [[C Arrays]] - **์ฐธ์กฐ ๋งฅ๋ฝ:** ๋ฐ˜๋ณต๋ฌธ ์„น์…˜ ๋งˆ์ง€๋ง‰ โ€” ๋ฐฐ์—ด(Arrays) ์„น์…˜์œผ๋กœ ์ด์–ด์ง. ## ๐Ÿ“š ์ถœ์ฒ˜ (Sources) - [S1] W3Schools โ€” C Break and Continue โ€” https://www.w3schools.com/c/c_break_continue.php ## ๐Ÿ“ ๋ณ€๊ฒฝ ์ด๋ ฅ (Change history) - 2026-07-04: Initial draft synthesized from the W3Schools "C Break and Continue" page (Astra wiki-curation, P-Reinforce v3.1 format).