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
- Routes exceptional conditions to shared cleanup and demonstrates how jumps affect local-object lifetime.
- How deep it goes
- Defines label visibility and jump limits, gives cleanup guidance, and works through compound-literal lifetimes; does not elaborate a general jump-based design method.
- Examples
- Uses an optimized printing function’s cleanup jump, a labeled repetition, and contrasting while-loop and goto compound literals.
- What you can do after
- Build it from scratch: write function-local cleanup jumps while avoiding skipped initializations and checking local-object lifetimes.
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.

