fork(1) download
  1. #include <stdio.h>
  2.  
  3.  
  4. void test(int i) {
  5. printf("%d is ", i);
  6. do {
  7. void * jump_table[] = {
  8. &&branch_default, &&branch_1,
  9. &&branch_default, &&branch_default,
  10. &&branch_default, &&branch_5,
  11. &&branch_default, &&branch_default,
  12. &&branch_8, &&branch_default
  13. };
  14. if (i < 0 || i >= 10)
  15. goto branch_default;
  16. goto *jump_table[i];
  17. branch_default:
  18. printf("default\n");
  19. break;
  20. branch_1:
  21. printf("one!\n");
  22. break;
  23. branch_5:
  24. printf("five!\n");
  25. break;
  26. branch_8:
  27. printf("eight!\n");
  28. break;
  29. } while (0);
  30. }
  31.  
  32.  
  33. int main() {
  34. int i;
  35. for (i=-1; i<12; i++) {
  36. test(i);
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 0s 2248KB
stdin
Standard input is empty
stdout
-1 is default
0 is default
1 is one!
2 is default
3 is default
4 is default
5 is five!
6 is default
7 is default
8 is eight!
9 is default
10 is default
11 is default