一行一行读取 解决多读一行的问题
注意不能用!EOF判断结尾
#include <stdio.h>
#include <gmp.h>
int main(int argc, char *argv[]){
FILE *f;
char *c;
int counter = 0;
if((f = fopen("./stage1.input","r")) ==NULL){
printf("cannot open the file\n");
}
while(!feof(f)){
if(gmp_fscanf(f,"%s",(c+counter)) == EOF ){
break;
}
// printf("%s \n",(c+i));
// printf("$$$$$$$$$$4 i is %d\n",i);
counter++;
}
printf("counter is %d\n",counter); // i = 30
if((counter %3) != 0){
printf("this file is uncompleted!!!\n");
}
printf("!!!! !!!\n" );
fclose(f);
return 0;
}