C语言的关于文件读取的有关问题

C语言的关于文件读取的问题
原题是:输入一个正整数n,然后读取n个正整数,最后再读取一个正整数m,统计有多少整数小于m。代码如下,
int main()
 {
 FILE *fin,*fout;
 fin = fopen("data.in","rb");
 fout = fopen("data.out","wb");
 int n,x,m,i,count = 0;
 fscanf(fin,"d",&n);
 printf("%d\n",n);
 i = 1L;
 while (feof (fin) == 0){
 fseek(fin,i,0);
 fscanf(fin,"d",&x);
 if (x < m){
 count++;
 }
 i++;
 }
 printf("%d\n",count);
 fclose(fin);
 fclose(fout);
 return 0;
 }
但是会陷入死循环,求大神解答
------解决方案--------------------
不知道是否符合,仅供参考:

#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fin,*fout;

fin = fopen("data.in","rb");
if(fin == NULL)
{
printf("fin null\n");
exit(1);
}
fout = fopen("data.out","wb");
 
int n,m,x,count = 0;

fscanf(fin,"%d",&n);
printf("n = %d\n",n);

fseek(fin,-2,SEEK_END);  //按你的题意,m是在文件最后,所以重新定位一下
fscanf(fin,"%d",&m);
printf("m = %d\n",m);

fseek(fin,2,SEEK_SET);//跳过已经输入的n
while(fscanf(fin,"%d",&x) == 1)
{
if (x < m)
{
 count++;
}
}
printf("count = %d\n",count);
fclose(fin);
fclose(fout);
return 0;
}

------解决方案--------------------
仅供参考C语言的关于文件读取的有关问题
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>

int main()
 {
 FILE* fp_in;
 FILE* fp_out;
 int* start;
 int* p;
 int n;
 int count=0;
 fp_in = fopen("data.in","rb");
 if(fp_in==NULL)
 {
 printf("FILES data.in can not open!\n");
 exit(1);
 }
 fp_out = fopen("data.out","wb");
 fscanf(fp_in,"%d",&n);
 p=start=(int*)malloc(sizeof(int)*n);
 for(;n>0;n--)
 {
 fscanf(fp_in,"%d",p);
 p++;
 }
 fscanf(fp_in,"%d",&n);
 for(p--;p>=start;p--)
 {
 if(*p<n)count++;
 }
 printf("%d\n",count);
 fclose(fp_in);
 fclose(fp_out);
 return 0;
 }