Guest User

Untitled

a guest
Jan 21st, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. main()
  4. {
  5. char line[100];
  6. char decision[100];
  7. printf("Are you gonna throw it?n");
  8. printf("Type yes or no.n");
  9.  
  10. scanf("%s", line);
  11. printf("%s n", line);
  12.  
  13. if (line == "yes") {
  14. printf("Thanks.n");
  15. } else if (line == "no") {
  16. printf("Why not?n");
  17. }
  18.  
  19. printf("Do you want to do this again?n");
  20. scanf("%s", decision);
  21. if (decision == "yes") {
  22. main();
  23. };
  24. }
  25.  
  26. if (strcmp(line, "yes") == 0) {
  27. printf("Thanks.n");
  28. } else if (strcmp(line, "no") == 0) {
  29. printf("Why not?n");
  30. }
  31.  
  32. if (strcmp(line, "yes") == 0) { ... }
  33.  
  34. if (decision == "yes")
  35. {
  36. main();
  37. }; //<-- if you want to keep this code at all
  38.  
  39. strcmp(decision, "yes"); //returns 0 if they are equil
  40.  
  41. main() {
  42. char line[100];
  43. char decision[100] = "yes";
  44. while(!strcmp(decision, "yes")){
  45. printf("Are you gonna throw it?n");
  46. printf("Type yes or no.n");
  47. scanf("%s", line);
  48. printf("%s n", line);
  49. if (!strcmp(line, "yes"))
  50. printf("Thanks.n");
  51. else if (!strcmp(line, "no"))
  52. printf("Why not?n");
  53.  
  54. printf("Do you want to do this again?n");
  55. scanf("%s", decision);
  56. } //end while
  57. } //end main
Add Comment
Please, Sign In to add comment