Hey, I'm relatively new to C++, started a few days ago and I'm new to this forum community as well. I made a simple program where the computer asks you for your name, then age, followed by your hometown and your occupation (in that order). It works fine, but there's one small problem. If I were to type my name in as "Bob Ray", it will read my name as "Bob" and my age as "Ray". I would like to fix that little problem. Here's my code...
#include <iostream>
#include <string>
using namespace std;
void Convo ();
string name, city, job, age;
void Convo ()
{
cout << "Hello! What's your name?" << endl;
cin >> name;
cout << endl;
cout << "Hi there, " << name << "." << endl;
cout << endl;
cout << "How old are you, " << name << "?" << endl;
cin >> age;
cout << endl;
cout << "Wow! " << age << " years old. You're ancient!" << endl;
cout << endl;
cout << "Where are you from?" <<endl;
cin >> city;
cout << endl;
cout << "Sounds like a fun place." << endl;
cout << endl;
cout << "What's your profession?" << endl;
cin >> job;
cout << endl;
cout << "Wow! You're a " << job << "!" << endl;
cout << endl;
cout << "Well that's all the questions I have for you." << endl;
cout << endl;
Convo();
}
int
main()
{
Convo();
return 0;
}
I'm using Bloodshed Dev C++ (if that matters). Also, if you could tell me how to allow the user to exit the program by hitting the 'Esc' key, I'd be entirely grateful.
Thanks for the help,
Trinimini