Goto
A goto statement or instruction unconditionally transfers program execution to a labeled statement or location within the current execution unit.
Modern C, Third Edition
goto is a C jump statement that transfers execution to a labeled statement within the same function.
- How it is used
- Uses local jumps chiefly to separate exceptional error cleanup from normal control flow.
- How deep it goes
- Explains label visibility, jump boundaries, initialization guidance, and the lifetime consequences of backward jumps.
- Examples
- Uses a backward-jump compound literal example and a buffer-printing function with shared cleanup after allocation errors.
- What you can do after
- Evaluate local jumps for cleanup and reason about their effects on object lifetime.
Modern C
goto is a C control-flow statement that transfers execution to a labeled statement within the same function.
- How it is used
- Handles exceptional control-flow changes, local cleanup, and selected algorithmic jumps within one function.
- How deep it goes
- Explains labels, same-function transfer, object lifetime, and scope interactions, while deferring fuller automatic-object rules.
- Examples
- Uses compound-literal retry examples, a contrived labeled jump, and a recursive descent parser for brace-based code indentation.
- What you can do after
- Apply it to exceptional cleanup and compact algorithmic control flow while checking object lifetime and pointer validity.
Related concepts
- labeluses · A label is a named code location or construct that control-flow operations can reference as a target.
- resource cleanupimplements · Resource cleanup is the release of resources or restoration of state when an operation or scope ends or fails.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

