fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int main(void)
  5. {
  6. char ingredient[100];
  7.  
  8. printf("Enter an ingredient: ");
  9. fgets(ingredient, 100, stdin);
  10.  
  11. if (strstr(ingredient, "sour cream") != NULL)
  12. {
  13. printf("Use yogurt instead.\n");
  14. }
  15. else if (strstr(ingredient, "sugar") != NULL)
  16. {
  17. printf("Use honey or applesauce instead.\n");
  18. }
  19. else if (strstr(ingredient, "butter") != NULL)
  20. {
  21. printf("Use margarine or yogurt instead.\n");
  22. }
  23. else if (strstr(ingredient, "white bread") != NULL)
  24. {
  25. printf("Use whole-grain bread instead.\n");
  26. }
  27. else if (strstr(ingredient, "flour") != NULL)
  28. {
  29. printf("Use rye or rice flour instead.\n");
  30. }
  31. else if (strstr(ingredient, "milk") != NULL)
  32. {
  33. printf("Use soy milk instead.\n");
  34. }
  35. else
  36. {
  37. printf("No substitution was found.\n");
  38. }
  39.  
  40. printf("\nAlways consult your physician before making significant changes to your diet.\n");
  41.  
  42. return 0;
  43. }
Success #stdin #stdout 0s 5348KB
stdin
Standard input is empty
stdout
Enter an ingredient: No substitution was found.

Always consult your physician before making significant changes to your diet.