Thanks for the tip Dave. This combo works fine indeed.
Code:
while ( fgets(buffer, 1024, in) )
{
// the first condition will fail so the second will be discarded automatically
if ( widthRead == 0 && sscanf(buffer, "Width:%d", &gContext.width) == 1 )
widthRead = !widthRead;
else if ( heightRead == 0 && sscanf(buffer, "Height:%d", &gContext.height) == 1 )
heightRead = 1;
else if ( initXYRead == 0 && sscanf(buffer, "InitXY(%d,%d)", &gContext.initX, &gContext.initY) == 2 )
initXYRead = 1;
else if ( CColRead == 0 && sscanf(buffer, "CCol:(%f,%f,%f)", &gContext.CCol.r, &gContext.CCol.g, &gContext.CCol.b) == 3 )
CColRead = 1;
else if ( i<10 && sscanf(buffer, "RGB(%f,%f,%f)", &gContext.preCol[i].r, &gContext.preCol[i].g, &gContext.preCol[i].b) == 3 )
i++;}
}
I wonder why the other piece of code didn't work...
This solution does what it was designed to do, however it seems like an overkill to me (even though I can't think of a more elegant solution).
Duetti