Simple function to split strings

I'm having a ton of trouble attempting to split a string using C++ string operations and looking at similar code is not helping because they all use string stream and arrays. I'm trying to take a name (ex: john b smith), change its order and capitalize the first letters (ex: Smith, John B) using .find. I really don't understand how to determine where to break a string when it is input by the user.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40


#include<iostream>
#include<string>

using namespace std;

string FixedName(string name);

int main()
{
	string name;
	string fixedname;
	char choice = 0;

	do
	{
		cout << "Enter a name first, middle initial, last: " << endl;
		getline(cin, name);
		fixedname = FixedName(name);
		cout << "You entered " << name << "." << " It was converted to " << fixedname << endl;
		cout << "Do you want to fix another name?(Y/N)" << endl;
		cin.ignore(80) >> choice;
	} while (toupper(choice) == 'Y');
}

string FixedName(string name)
{
	string first, middle, last;
	
	
			first = name.substr();  //no idea what do do here...
			middle = name.substr();
			last = name.substr();
		
			name = last + first + middle;

	return name;
	
}
Please help...
Topic archived. No new replies allowed.