`goto` — C Keyword
`goto` — C Keyword
The goto keyword in C: unconditional jump to a labeled statement in the same function.
`goto` — C Keyword
The goto keyword in C: unconditional jump to a labeled statement in the same function.
Use reference pages to confirm names, categories, nearby facilities, and the constraints that matter before writing or reviewing code.
goto (C)Unconditionally transfers control to a labeled statement within the same function.
goto label;
// ...
label: statement
#include <stdio.h>
int main(void) {
/* Error-cleanup pattern common in C */
FILE* f = fopen("data.txt", "r");
if (!f) goto cleanup;
/* process f... */
fclose(f);
return 0;
cleanup:
fprintf(stderr, "Failed to open file\n");
return 1;
}
goto cannot jump over a variable-length array (VLA) declaration into its scope.goto cleanup) is accepted idiomatic C.gotoint main() {
// Pick one facility from this reference page.
// Write the smallest program that exercises its main precondition,
// complexity rule, or lifetime constraint before scaling up.
return 0;
}