fscanf with while loop

assume $num is the number what you assign through scanf or fscanf or sscanf and so on.

while (fscanf(fileptr, formatstring, &var1, &var2,...)!=$num) {
    //do some thing.      
}
fclose(fileptr);

if you encounter invalid pointer, check memory and pointer operation anywhere first.
because i have written this template but still stuck with invalid pointer. i found other pointer operation error finally.

原文地址:https://www.cnblogs.com/ijpq/p/15428304.html