【发布时间】:2015-07-19 22:09:39
【问题描述】:
我想检查我的文本文件是否包含数据。如果文件包含我要读取的数据。我的问题是我不知道在 if 语句中写入的正确条件。 提示:我尝试使用 fseek 和 ftell 的功能,但没有任何好处。 我想知道为什么if语句中的这个条件不能正常工作?
FILE *fptr;
if(ftell(fptr)!=0){ //check if the file is not empty.
if ( !( fptr = fopen( "saving.txt", "r" ))){
printf( "File could not be opened to retrieve your data from it.\n" );
}
else{
while ( !feof( fptr ) ){
fscanf( fptr, "%f\n", &p.burst_time );
AddProcess(&l,p.burst_time);
}
fclose( fptr );
}
}
【问题讨论】:
标签: c