I want to check if my text file contains data or not. If the file contains a data I want to read it. My problem is I don't know the right condition to write in the if statement. Hint: I tried to use the functions of fseek & ftell, but without any benefit. I want to know why this condition in the if statement doesn't work properly?
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 );
}
}