You cannot save the lines inside the array, it can only contain one string per cell and you want to put 3, also you forgot to add the elements inside the array:
You need a 2D array:
string jobcharge[10][3];
int x = 0;
while(!infile.eof()) // To get you all the lines.
{
getline(infile,STRING); // Saves the line in STRING.
stringstream ss(STRING);
std::string token;
int y = 0;
while(std::getline(ss, token, ','))
{
std::cout << token << '\n';
jobcharge[x][y] = token;
y++;
}
x++;
}
Then you can print the array like this:
for(int a= 0 ; a < 10 ; a++ )
{
for(int b= 0 ; b < 3 ; b++ )
{
cout << jobcharge[a][b] << endl;
}
}
Bear in mind that this code will completely fail is you have more than 10 lines or more than 3 items per line. You should check the values inside the loop.