编程论坛---最好的编程学习论坛
打印

如何查找文件里的数据

如何查找文件里的数据

#include<stdio.h>
#include<stdlib.h>
#define SIZE 3
struct person
{
        char num[2];
        float cash;
        char sec[3];
}per[SIZE];
void main()
{
        int i;
        FILE *fp;
        if((fp=fopen("txt.txt","r"))==NULL)
        {        printf("akfh\n");
        exit(0);
        }

for(i=0;i<SIZE;i++)
{fscanf(fp,"%s %f %s",per.num,&per.cash,per.sec);
printf("%s %5.2f %s\n",per.num,per.cash,per.sec);

}
fclose(fp);
}


请教一下,应该怎么继续下去,目的是输入一个数查找出他所匹配的信息

TOP