How do I output specific parts of a string that I don't specifically know what is assigned to it. Like the information assigned to the string is determined by the person running the program. Specifically here is the start of my program
string name;
cout >> "please enter your full name: " >> name >> endl;
getline (cin, name);
I want to take that full name and output only parts of it. Specifically the first, middle, and last names on separate lines.
And I doubt you ever will. A split function is just a function that splits a string into several parts using a delimiter (a space here (and other whitespace)). It has nothing to do with C++ itself. Instead of using istream iterators, you can just look for the spaces manually and use substr.
You can also do it using operator>>:
1 2 3
stringstream ss(str);
string first,middle,last;
ss >> first >> middle >> last;