Hi all this is my codeWhen i have typed "1" it says well then i type something and the box closes i've tried using multiple cin.get;'s but not much seems to work anyone got any ideas?Code:#include <iostream.h> #include <string.h> void prompt1(); int prompt2(); void greeting(); int main() { prompt1(); switch (prompt2()) { case 1: cout<<"Well? "; greeting(); break; case 2: cout<<"Meanie"<<endl; break; default: cout<<"Huh?"<<endl; break; } return 0; } void prompt1() { char answer[50]; cout<<"How are you? "; cin.getline(answer, 50); cout<<"You are: "<< answer <<endl; } int prompt2() { int answer; cout<<"Aren't you going to ask how I am?\n"; cout<<"1) Yes\n2) No\n: "; cin>> answer; cin.ignore(); return answer; } void greeting() { char greeting[50]; cin.getline(greeting, 50); if (strcmp(greeting, "How are you?") != 0) { cout<<"You still haven't asked me how I am!"<<endl; } else { cout<<"I'm fine, thank you."<<endl; } }



LinkBack URL
About LinkBacks



