I think I need a small split string program with a getLine function to do "exactly" this:
(Please notice the user type his full name on one line, but the program output First and Last name on separate lines.)
Please type your first and last name:
Sam Harris
Your First Name is:
Sam
Your Last Name is:
Harris
Below is some code I been playing around with, with no success. It is "TOTALLY" useless because it needs user input from the keyboard as described above. Not embedded names like I have in the code below. Can some one fix this or would you have an working example to archive what I'm after which is color-coded above.
Hope I made my question clear.Code:#include <iostream> #include <sstream> #include <string> using namespace std; int main() { // useless. We need user keyboard input. Not embedded // names and it must be in Standard C++. string s("Sam Harris"); istringstream iss(s); string sub; iss >> sub; cout << "First Name: " << sub << endl; iss >> sub; cout << "Last Name: " << sub << endl; return 0; }
Thanks in advance



LinkBack URL
About LinkBacks




and it looks a whole lot better on your post and you will never find anything like it any where when googling. At lease I could not for over 72 hours. .. Thank you