No Aisthesis . It should not be an embeded name. The first example I posted was just a piece of code I came up with while trying. Working code should display on screen from anyone who type there name full name at the keyboard. I don't know how to make it work with getLine of set-up the std::cin >> sub thing. I am brand new learning C++. I love the way C++ people talk code, but I got to see code examples to get an understanding of how the code work. This is my 3rd week.
(Please notice the user type his full name on one line, but the program output First and Last name on separate lines. Number 2 is the one I am trying to do)
1) Everybody knows how to output a single line like this:
Please type your first and last name:
John Doe
Thankyou
2) But it seem no one knows how to output to seperate lines like this:
Please type your first and last name:
John Doe
Your First Name is:
John
Your Last Name is:
Doe
This code is a little mix-up but I'm sure it's only a hair away from working.
I just don't know how to get it to work:
Code:
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main()
{
string s("Sam Harris");
istringstream iss(s);
string sub;
iss >> sub;
cout << "First Name: " << sub << endl;
iss >> sub;
cout << "Last Name: " << sub << endl;
string str;
cout << "Please enter full name: ";
getline (cin,str);
cout << "Thank you, " << str << ".\n";
return 0;
}