ACtually, I have another question about this. Here is my working code:
Code:
int countTimeSteps(FILE *input)
{
char line [MAXNUM];
int check,x,N_timeSteps;
N_timeSteps = 1; //since there is one for time == 0, start at 1
fgets(line, MAXNUM, input);
while (fgets(line, MAXNUM, input) != NULL) //read in file 1 line at a time
{
//puts(line);
check = sscanf(line,"%d",&x); //x is useless, only there to make sscanf stop whining about arguments
if (check != 0 && check != EOF) //if the line contains an integer value at the start
{
++N_timeSteps;
}
}
return N_timeSteps;
}
My question is this:
right now, the code will count any line that starts with an integer. Is there a way to specify that it count only lines that contain ONLY a single integer, rather than lines the simply begin with one? For the current case it doesn't matter, but it would help make the code a little more robust.