assign std::string (from getline) to std::string*

I need to read in a file like this:


1
2
3
4
 , ,
1, ,
 ,1,
 , ,


and do something with the strings '1'. They must be assigned to externalData[gtrstring][place] in the following code:

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
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;

int main(void)
{
    std::ifstream infile("mozzarella.txt");
    std::string line;
    int places = 0;
    int lines = 0;
    std::string finger;
    while (std::getline(infile, line))
    {
        std::stringstream linestream(line);
        
        places = 0;
        while(getline(linestream,finger,','))
        {
            std::cout << finger << ";";
            
            places++;
        }
        std::cout << "\n";
        lines++;
    }
    
    int internalData[lines][places];
    std::string *externalData[lines][places];
    
    std::ifstream infile2("mozzarella.txt");
    int gtrstring = 0;
    int place = 0;
    std::string fingerstr;
    while (std::getline(infile2, line))
    {
        std::stringstream linestream(line);
        
        place = 0;
        while(getline(linestream,fingerstr,','))
        {
            externalData[gtrstring][place] = fingerstr;//error
            std::cout << externalData[gtrstring][place] << "-";
            place++;
        }
        std::cout << "\n";
        gtrstring++;
    }
    
    return 0;
}


I am getting the error:

1
2
3
4
5
test.cpp:45:44: error: assigning to 'std::string *' (aka 'basic_string<char,
      char_traits<char>, allocator<char> > *') from incompatible type
      'std::string' (aka 'basic_string<char, char_traits<char>, allocator<char>
      >'); take the address with &
            externalData[gtrstring][place] = fingerstr;


What do I have to do?
remove asterisk from line 30. There is no reason to use pointers in first place.
Topic archived. No new replies allowed.