Hallo. Ik probeer een textbestand te lezen. Ik loop vast op dit stuk.
{57, 5, 6, 74, 7}
{78, 7, 5, 8, 6}
{5, 3, 4, 7, 4}
{37, 2, 2, 9, 5}
{8, 5, 3, 2, 4}
[CPP]
string temp = cur_line;
if(temp[0] == '{'){
string temp2 = parser_.removeSymbol(temp, ' ');
temp = parser_.removeSymbol(temp2, '}');
std::string token;
std::istringstream ss1(temp);
std::istringstream ss2("");
std::vector<int> row;
int int_value;
while(getline(ss1, token, ',')){
ss2.clear();
ss2.str("");
ss2.str(token);
ss2 >> int_value;
row.push_back(int_value);
}
column.push_back(row);
}
[/CPP]
de output hiervan is:
-1 5 6 74 7
7 7 5 8 6
6 3 4 6 4
4 2 2 9 5
5 5 3 2 4
Zoals je ziet zijn bijna alle waarden goed gelezen, behalve steeds de eerste waarde van een regel. Heeft iemand een idee hoe dit op te lossen is?
{57, 5, 6, 74, 7}
{78, 7, 5, 8, 6}
{5, 3, 4, 7, 4}
{37, 2, 2, 9, 5}
{8, 5, 3, 2, 4}
[CPP]
string temp = cur_line;
if(temp[0] == '{'){
string temp2 = parser_.removeSymbol(temp, ' ');
temp = parser_.removeSymbol(temp2, '}');
std::string token;
std::istringstream ss1(temp);
std::istringstream ss2("");
std::vector<int> row;
int int_value;
while(getline(ss1, token, ',')){
ss2.clear();
ss2.str("");
ss2.str(token);
ss2 >> int_value;
row.push_back(int_value);
}
column.push_back(row);
}
[/CPP]
de output hiervan is:
-1 5 6 74 7
7 7 5 8 6
6 3 4 6 4
4 2 2 9 5
5 5 3 2 4
Zoals je ziet zijn bijna alle waarden goed gelezen, behalve steeds de eerste waarde van een regel. Heeft iemand een idee hoe dit op te lossen is?