1
0

global.c 542 B

1234567891011121314151617181920212223
  1. /* global.c -- uses an external variable */
  2. #include <stdio.h>
  3. int units = 0; /* an external variable */
  4. void critic(void);
  5. int main(void)
  6. {
  7. extern int units; /* an optional redeclaration */
  8. printf("How many pounds to a firkin of butter?\n");
  9. scanf("%d", &units);
  10. while ( units != 56)
  11. critic();
  12. printf("You must have looked it up!\n");
  13. return 0;
  14. }
  15. void critic(void)
  16. {
  17. /* optional redeclaration omitted */
  18. printf("No luck, my friend. Try again.\n");
  19. scanf("%d", &units);
  20. }