Can Anyone Help!! This Is Bugging Me
What's Up everyone, if anyone can help it would be appreciated.
My problem with this program (see output at very bottom) is that
I can use it once,and see one person's age, but when i try to input a second or third name after the first time, and press enter, the DOS Window closes on me. What can I do to keep this Program running for as long as I want?
#include <fstream.h>
#include <string.h>
#include <conio.c>
char response [10]; //not sure what this does (10)
int main()
{
cout << "\n Input the name Christian, Valerie, or Olivia to see their age.\n";
cin >> response;
while(strstr(response,"Christian")!=NULL)
{
cout << response << " is 20 years old.\n";
getch();
return 0;
}
while(strstr(response,"Valerie")!=NULL)
{
cout << response << " is 15 years old.\n";
getch();
return 0;
}
while(strstr(response,"Olivia")!=NULL)
{
cout << response << " is 8 years old.\n";
getch();
return 0;
}
return 0;
}
/*OUTPUT*************
Input the name Christian, Valerie, or Olivia to see their age
Christian (let's say i put this in)
Christian is 20 years old (this is the output)