54_goto.c 612 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include <stdio.h>
  2. void fred()
  3. {
  4. printf("In fred()\n");
  5. goto done;
  6. printf("In middle\n");
  7. done:
  8. printf("At end\n");
  9. }
  10. void joe()
  11. {
  12. int b = 5678;
  13. printf("In joe()\n");
  14. {
  15. int c = 1234;
  16. printf("c = %d\n", c);
  17. goto outer;
  18. printf("uh-oh\n");
  19. }
  20. outer:
  21. printf("done\n");
  22. }
  23. void henry()
  24. {
  25. int a;
  26. printf("In henry()\n");
  27. goto inner;
  28. {
  29. int b;
  30. inner:
  31. b = 1234;
  32. printf("b = %d\n", b);
  33. }
  34. printf("done\n");
  35. }
  36. int main()
  37. {
  38. fred();
  39. joe();
  40. henry();
  41. return 0;
  42. }
  43. /* vim: set expandtab ts=4 sw=3 sts=3 tw=80 :*/