A label in a programming language is a sequence of characters that identifies a location within source code. In most languages labels take the form of an identifier, often followed by a punctuation character (e.g., a colon). In many high level programming languages the purpose of a label is to act as the destination of a GOTO
statement. In assembly language labels can be used anywhere an address can (for example, as the operand of a JMP
or MOV
instruction). Also in Pascal and its derived variations. Some languages, such as Fortran and BASIC, support numeric labels. Labels are also used to identify an entry point into a compiled sequence of statements (e.g., during debugging).
In C a label identifies a statement in the code. A single statement can have multiple labels. Labels just indicate locations in the code and reaching a label has no effect on the actual execution.
Function labels consist of an identifier, followed by a colon. Each such label points to a statement in a function and its identifier must be unique within that function. Other functions may use the same name for a label. Label identifiers occupy their own namespace - one can have variables and functions with the same name as a label.
Here error is the label. The statement goto can be used to jump to a labeled statement in the code. After a goto
, program execution continues with the statement after the label.