C goto statement

Description

The goto statement directs the flow of statements to a label.

Syntax

The goto statement ends with a label and a semicolon.

goto there;

A statement label is a name followed by a colon (:) to separate it from the statement it labels.

there: x = 1;

Example


#include <stdio.h>
// w  w w  .j  a  va 2 s.  com
int main(void) {

  int i;

  i = 1;

  again:
  printf("%d ", i);
  i++;
  if(i<10) {
      goto again;
  }
  return 0;
}




















Home »
  C Language »
    Language Basics »




C Language Basics
Data Types
Operator
Statement
Array