#include <stdio.h>
#include <stdlib.h>
typedef struct BasicItem
{
char num[10];//编号
char mingzi[50];//姓名
char sex[2];//性别
char age[4];//年龄
char tiwen[10];//当日体温
char tel[20];//电话
char shenfenzheng[20];//身份证号
}BI1;
BI1 iom[1000];
typedef struct BasicItem2
{
char num[10];//编号
char mingzi[50];//姓名
char sex[2];//性别
char age[4];//年龄
char tiwen[10];//当日体温
char tel[20];//电话
char shenfenzheng[20];//身份证号
}BI2;
BI2 iom2[1000];
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main() {
FILE *fp2;//文件指针
/*读取文件行数信息*/
int c=0,count=0,i,x;
fp2=fopen("E:\\Dev项目保存\\人员信息.txt","r");
while(!feof(fp2))
{
c=fgetc(fp2);
if(c=='\n'||c==EOF)
count++;
};
x=count-1;
printf("%d",x);
for(i=0;i<count;i++)
{
fscanf(fp2," %s %s %s %s %s %s %s",iom2[i].num,
iom2[i].mingzi,
iom2[i].sex,
iom2[i].age,
iom2[i].tiwen,
iom2[i].tel,
iom2[i].shenfenzheng);
printf(" \t%s \t%s \t%s \t%s \t%s \t%s \t%s\n",iom2[i].num,
iom2[i].mingzi,
iom2[i].sex,
iom2[i].age,
iom2[i].tiwen,
iom2[i].tel,
iom2[i].shenfenzheng);
}
fclose(fp2);/*执行功能函数*/
return 0;
}
读取都是0,输入是正常输入,类型都是char