pointing to an array of strings

Hi I have a program that splits up a file and creates a pointer to an array of strings and I was trying to assign the pointer to another array of strings, but I think it is looking at the strings as a char

here is my string splitter file
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
54
55
56
#ifndef STRINGSPLITTER_H
#define STRINGSPLITTER_H

#include <string>
#include <vector>

using namespace std;

class StringSplitter
{
public:

	//Accepts a string and a delimiter.  Will use items_found to return the number
	//of items found as well as an array of strings where each element is a piece of
	//the original string.
	static string * split(string text, string delimiter, int &items_found)
	{
		//vectors are dynamically expanding arrays
		vector<string> pieces;

		//find the first delimiter
		int location = text.find(delimiter);

		//we are starting at the beginning of our string
		int start = 0;

		//go until we have no more delimiters
		while(location != string::npos)
		{
			//add the current piece to our list of pieces
			string piece = text.substr(start, location - start);
			pieces.push_back(piece);

			//update our index markers for the next round
			start = location + 1;
			location = text.find(delimiter, start);
		}

		//at the end of our loop, we're going to have one trailing piece to take care of.
		//handle that now.
		string piece = text.substr(start, location - start);
		pieces.push_back(piece);

		//convert from vector into an array of strings
		int size = pieces.size();
		string *pieces_str = new string[size];
		for(int i = 0; i < size; i++)
		{
			pieces_str[i] = pieces.at(i);
		}
		items_found = size;
		return pieces_str;			
	}
};

#endif 


and here is my program im trying to use it in

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class employeefactory
{
private:
StudentEmployee* studentFromString(string text)
	{
		string employee[6];
		int number_items;
		StringSplitter files;
		string* pointer = &employee[0];

		

	pointer =	files.split(text,",",number_items);

	StudentEmployee* student = new StudentEmployee(employee[0],atoi(employee[1].c_str),string_to_bool(employee[2]),
						string_to_bool(employee[4]),atoi(employee[3].c_str),atof(employee[5].c_str));
	return student;
	}

how to initialize student employee
1
2
3

StudentEmployee( string name , int id, bool is_working,bool is_work_study,
					 int hours_worked, double pay_rate)




the error im getting is:
c:\users\chase\documents\visual studio 2012\projects\hw3\hw3\employeefactory.h(24): error C3867: 'std::basic_string<_Elem,_Traits,_Alloc>::c_str': function call missing argument list; use '&std::basic_string<_Elem,_Traits,_Alloc>::c_str' to create a pointer to member
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Alloc=std::allocator<char>
1> ]

I don't really know how to fix this error and I can't move on till I fix it so any help is appreciated
Why not just return the std::vector<std::string>? Why are you trying to deal with pointers at all?
I loose credit on the assignment if I change certain predefined functions in my teachers UML diagram
Topic archived. No new replies allowed.