I am trying to parse a file. I am currently using the following code, but would like to replace it with a sstream based solution
unsigned int vertexIndex[3], uvIndex[3], normalIndex[3];
const char* cstring = line.c_str();
int matches = sscanf(cstring, "f %d/%d/%d %d/%d/%d %d/%d/%d\n", &vertexIndex[0], &uvIndex[0], &normalIndex[0], &vertexIndex[1], &uvIndex[1], &normalIndex[1], &vertexIndex[2], &uvIndex[2], &normalIndex[2]);
When I try the following, I get unexpected results
std::stringstream f(line);
f >> vertexIndex[0] >> uvIndex[0] >> normalIndex[0] >> vertexIndex[1] >> uvIndex[1] >> normalIndex[1] >> vertexIndex[2] >> uvIndex[2] >> normalIndex[2];
I am sure I am misunderstanding the stream use somehow... any help would be awesome!