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.
What to know first
- compound literalA compound literal is a C expression consisting of a parenthesized type name followed by an initializer that creates an unnamed object.
- control flowControl flow is the order and branching of execution that determines which operations in a program or process run and when.
- loopA loop is a programming-language control-flow construct that repeatedly executes a block of instructions according to an iteration rule or continuation condition.
- referenceA reference is an indirect value, binding, or relationship that identifies or provides access to another object, value, resource, or source.
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.
Questions about goto
What is goto?
A goto statement or instruction unconditionally transfers program execution to a labeled statement or location within the current execution unit.
Which Manning books explain goto?
Modern C, Third Edition and Modern C.
What should I know before learning goto?
Manning books that teach goto usually introduce compound literal, control flow, loop and reference first.
What is the difference between goto and structured program?
A goto statement or instruction unconditionally transfers program execution to a labeled statement or location within the current execution unit. A structured program is a program whose control flow is organized through sequencing, selection, iteration, and procedure calls rather than arbitrary jumps.
What is goto a kind of?
Goto is a kind of unconditional jump instruction. An unconditional jump instruction is a control-flow operation that transfers execution to a specified location without evaluating a condition.
What is goto part of?
Goto is part of function body. A function body is the block or sequence of code that specifies the computation or actions performed when a function is invoked.
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.

