我用如下程序:
#include <stdlib.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
struct Date
{
int da_year;
int da_day;
int da_mon;
};
struct Time
{
unsigned int ti_min;
unsigned int ti_hour;
unsigned int ti_hund;
unsigned int ti_sec;
};
struct User
{
long U_Num;
char U_Name[20];
char U_Pwd[20];
int BorrowNum;
long Borrow[3];
struct Date BorrowTime[3];
char Super[4];
char Xuehao[12];
char QQ[11];
char Email[25];
char Tel[16];
char Address[30];
char Remark[50];
};
int LoginFrm()
{
char ch;
int n=0,i;
FILE *fp;
struct User UserList[100];
fp=fopen("User.dat","rb");
if(fp==NULL)
{
printf("can open the file");
return 0;
}
else
for(n=0;n<100;n++)
{
fread(&UserList[n],sizeof(struct User),1,fp);
printf("%5f,%-5s,%-5s\n",UserList[n].U_Num,UserList[n].U_Name,UserList[n].U_Pwd);
getch();
}
fclose(fp);
return 1;
}
int main()
{ return(LoginFrm());
}
想看