76 361
Assignments Done
Successfully Done
In May 2019

Answer to Question #25040 in C++ for hanrik

Question #25040
Write a C++ program that accepts the complete name of a person (first middle last) then print them separately.
Expert's answer
#include <iostream>

#include <sstream>
#include <string>
using namespace std;

int main()

// useless. We need user keyboard input. Not embeded name
// in Standard C++ which is the norm.

string s("John Doe");
istringstream iss(s);

string sub;
iss >> sub;
cout << "First Name: " << sub << endl;

iss >> sub;
cout << "Last Name: " << sub << endl;
return 0;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions