Hello,
IMHO there's an error in the first version of your code ( the second strtok); this is my version of code (probably is what you wanted); anyway it doens't work because at //*, line takes "nullptr" and this first loop end...any hints?
vector<double> v;
vector< vector<double> > doubleVector;
char* line;
line = strtok(_buffer, "\r\n");
while ( line != NULL ) {
cout << line << endl;
char* value = strtok(line, ",");
while ( value != NULL) {
cout << value << endl;
v.push_back( strtod(value, NULL) );
value = strtok(NULL, ",");
}
doubleVector.push_back(v);
v.clear();
line = strtok(NULL, "\r\n"); //* <------ problem
}
vector<double> v;
vector< vector<double> > doubleVector;
char* line;
line = strtok(_buffer, "\r\n");
while ( line != NULL ) {
cout << line << endl;
char* value = strtok(line, ",");
while ( value != NULL) {
cout << value << endl;
v.push_back( strtod(value, NULL) );
value = strtok(NULL, ",");
}
doubleVector.push_back(v);
v.clear();
line = strtok(NULL, "\r\n"); //* <------ problem
}
To copy to clipboard, switch view to plain text mode
Bookmarks