I am trying to parse some results from a file and read, let us say, the first 2 lines of it in a C program. Here is what I am doing:
int i=0;
while (fgets(line_string, line_size, fp) != NULL){
if (i==0){
some_variable = ((int) atoi(line_string));
i++;
}
if (i==1){
some_other_variable = ((int) atoi(line_string));
i++;
}
else{
break;
}
}
But the problem is line_string keeps pointing to the first line of the file and doesn't progress in the while loop. What am I doing wrong?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…