this looks like a problem to me:
Code:
while (temp[0] == '#' || temp[0] == '\r' || temp[0] == '\0' || temp[0] == '\n' || strlen(temp) == 0)
{
filestr.getline(temp,256);
}
i think should be:
Code:
while (temp[0] == '#' || temp[0] == '\r' || temp[0] == '\0' || temp[0] == '\n' || strlen(temp) != 0)
also, in your 'else' condition, you make a call to getline( )
Code:
else
{
sDemoActInFrame tempDemoAct;
sscanf ( temp, " %d : %d : %d : %d ",
&(tempDemoAct.frame), &(tempDemoAct.action), &(tempDemoAct.cursorX),
&(tempDemoAct.cursorY));
mDemoActList.push_back(tempDemoAct);
filestr.getline(temp,256);
which could be subsequently called again in your initial 'if' condition.. without any push_back( ) operations in between.. this will overwrite the value of whatever 'temp' was holding.
Code:
while (temp[0] == '#' || temp[0] == '\r' || temp[0] == '\0' || temp[0] == '\n' || strlen(temp) == 0)
{
filestr.getline(temp,256); // <--Possible subsequent call to getline( ) from a previous 'else' operation in the loop
}
also, i think this should be called before entering the loop.. instead of repeatedly creating new objects on every 'else' case loop iteration:
Code:
sDemoActInFrame tempDemoAct; //Create this object before entering the loop and reuse it as necessary
suggestion:
Here is what i think is a better way to make sure you have read to 'end of file'. You used a sentinal char value of ':' to indicate that you have read to end of file.. another way to do this is to test the return value of getline( ):
try this:
Code:
while(filestr.getline(temp,256))
{
stuff...
...
...
}
This observations may or may not fix your segmentation problem... post ye' code if you continue to have trouble.