马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
typedef struct Account
{
char cardNum[17];
char password[7];
char userName[10];
char balance[20];
struct Account* next;
}LIST;
LIST* head=NULL;
LIST* p = NULL;
void initialize() {
FILE* fp;
LIST* tail,*temp;
head = (LIST*)malloc(sizeof(LIST));
tail = head;
p = head;
if ((fp = fopen("D:\\华软2021-2022\\c2\\ATM模拟机\\accounts.txt", "r")) == NULL) {
printf("文件打开错误");
exit(0);
}
while (1) {
temp = (LIST*)malloc(sizeof(LIST));
fscanf(fp, "%s\t%s\t%s\t%s\n", temp->cardNum, temp->password, temp->userName, temp->balance);
temp->next = NULL;
tail->next = temp;
tail = temp;
if (feof(fp)) {
break;
}
}
fclose(fp);
}
void freeSpace() {
LIST* temp = p->next;
while (temp!=NULL) {
p = temp->next;
free(temp);
temp = p;
}
}
|