fork download
  1. #include <stdio.h>
  2. #include <ctype.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. void lowerize(char *c) {
  7. while (*c != '\0') {
  8. *c = tolower(*c);
  9. c++;
  10. }
  11. }
  12.  
  13. int main(void) {
  14. char *q_and_a[][2] = {
  15. {"What happened after your mama went out in high heels?", "she struck oil"},
  16. {"What happened when Dracula bit your mama's neck?", "he got diabetes"},
  17. {"What does your mama need to do Wii fit?", "cheat codes"},
  18. {"What happened when I swerved to avoid your mama in the middle of the road?", "i ran out of gas"},
  19. {"Why does your mama wear a watch on both wrists?", "one for each timezone"},
  20. {"How did your mama get an ipad?", "by sitting on her iphone"},
  21. {"What does your mama's cereal bowl come with?", "a lifeguard"}
  22. };
  23.  
  24. char input[100];
  25. int room = 0;
  26.  
  27. while (room < 7) {
  28. printf("Room %d: %s\n> ", room + 1, q_and_a[room][0]);
  29. if (fgets(input, 100, stdin) == NULL) exit(0);
  30. input[strcspn(input, "\n")] = '\0';
  31. lowerize(input);
  32. if (strcmp(input, q_and_a[room][1]) == 0) room++;
  33. }
  34. puts("Congratulations, you have escaped the building!");
  35. return 0;
  36. }
Success #stdin #stdout 0s 5304KB
stdin
Standard input is empty
stdout
Room 1: What happened after your mama went out in high heels?
>