Hello All...
Made my tiny little program for entering a name. However, when the user inputs the second name, its viewed as a number (I'm guessing because of the space). How do I fix this so the user can enter a first and last name with a space in between.
Code:
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
string name = "";
float X,Y;
int main ()
{
// Greeting's to ask for a name //d
cout<< "Hello Carbon Life-Based Being!" << endl;
cout<< endl << "What's your name? ";
cin >> name;
cout << endl << "Hello " << name.c_str()
<< ", my name is Louis!"
<< endl
<< endl;
cout << endl
<< endl << "I hope your feeling well today " << name.c_str()
<< endl
<< endl;
Oh...I didn't think of it that way. I now have: cin >> name >> name
I don't know if that's the correct way to do it, but it does allow a space in between. The problem is the program will not run until a second name is input. If the user only uses one name, and presses enter. the courser only keeps moving down.
Thanks
Charles
PS. why do I not need the .c_str() here?