#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
usingnamespace 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;