#include #include #include //for string using namespace std; int main() { cout << "What would you like to eat? "; string food; //looks uninitialized, but initialized to empty string cin >> food; //input one word if (!cin) { cerr << "Sorry, couldn't input the string.\n"; return EXIT_FAILURE; } cout << "You can't have that because it "; if (food.find("sugar") == string::npos) { cout << "turns to sugar in your stomach.\n"; } else { cout << "has suger in it.\n"; } cout << "Incidentally, \"" << food << "\" is " << food.size() << " character(s) long.\n"; //Input and discard the newline that you typed //immediately after the name of the food. cin.ignore(1, '\n'); //Input an entire line (i.e., everything up to and including the next //newline), not just one word. Discard the newline. //getline(cin, food); return EXIT_SUCCESS; }