convert a vector of strings to vectors of char

I have a vector of string which, say, contains three words:
send more money

I want to convert this string to three different vectors of char.

I want to copy each word to its own vector of char.

How can I do that?


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
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include <cctype>
#include <string>
#include <vector>
#include <cstdlib>
using namespace std;

void inputToStrings(string str)
{
	string temp;
	vector <string> strings;
	bool occurring = false;       // true = string is occurring
	int sz = str.size();
	//transforming the line to a vector of strings.
	for (int i = 0; i < sz; i++)
	{
		if (!occurring && isalpha(str[i]))
		{
			occurring = true;
		}
		else if (!isalpha(str[i]) && occurring)
		{
			strings.push_back(temp);
			temp = "";
			occurring = false;
		}
		if (occurring)
		{
			temp = temp + str[i];
		}
	}
	if (temp != "")
	{
		strings.push_back(temp);
	}
	for (int i = 0; i < strings.size(); i++)
	{
		cout << strings[i] << endl;
	}

	//transofrming the vector of strings to vector of chars.


}

int main()
{
	string userInput;
	getline(cin, userInput);
	inputToStrings(userInput);
	system("PAUSE");
	return 0;
}
Take a look at this thread, the last example:
http://www.cplusplus.com/forum/beginner/87238/
Topic archived. No new replies allowed.