C Tutorial Switch Statement
The C Language
C History
BCPL
Euclid’s Algorithm in C
Euclid on the PDP-11
Pieces of C
C Types
Declarators
Struct bit-fields
Code generated by bit fields
C Unions
Layout of Records and Unions
C Storage Classes
malloc() and free()
Dynamic Storage Allocation
Simple Dynamic Storage Allocation
malloc() and free() variants
Fragmentation
Fragmentation and Handles
Automatic Garbage Collection
Arrays
Lazy Logical Operators
The Switch Statement

setjmp/longjmp: Sloppy exceptions
Nondeterminism in C

 

 

HOME
 


switch (expr) { 

case 1: /* ... */

break;

tmp = expr;

if (tmp == 1) goto  L1;

 

else

if

(tmp

==

5)

goto

L5;

else

if

(tmp

==

6)

goto

L6;

else goto Default; L1: /* ... */

goto Break;

 

case

5:

 

 

 

L5:

;

 

 

case

6:

/*

...

*/

L6:

/*

...

*/

 

break;

default: /* ... */

break;

}

goto Break;

Default: /* ...  */

goto Break; Break:

 

Sparse labels tested sequentially

 

if (e == 1) goto L1; 

Text Box: else
if
(e
==
else
if
(e
==
 

 

10) goto L10;

100) goto L100;

 Dense cases uses a jump table:  

/* uses gcc extensions */

 

static void *table[] =

 

{ &&L1, &&L2, &&Default, &&L4, &&L5 };

 

if (e >= 1 && e <= 5) goto *table[e];

 

Contact for more learning: webmaster@freehost7com