Namespaces
Variants
Actions

break statement

From cppreference.com
< c‎ | language

Causes the enclosing for, while or do-while loop or switch statement to terminate.

Used when it is otherwise awkward to terminate the loop using the condition expression and conditional statements.

Contents

[edit] Syntax

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

Appears only within the statement of a loop body (while, do-while, for) or within the statement of a switch.

[edit] Explanation

After this statement the control is transferred to the statement or declaration immediately following the enclosing loop or switch, as if by goto.

[edit] Keywords

break

[edit] Notes

A break statement cannot be used to break out of multiple nested loops. The