master
Cyfarthfa 6 years ago
parent dbfb888a73
commit 6044bd47d1

@ -1 +1 @@
114514 Cierra famale 114514 0
1 1 1 1 0

@ -7,19 +7,19 @@
#define N 50
int k = 1, n = 0, m = 0;
typedef struct student {
typedef struct Bank {
char no[13];//卡号
char name[10];//姓名
char sex[8];//性别
int balance;//余额
char passwd[20];
} student, stu[max];
void fileWrite(int n, stu s);
} bank, ban[max];
void fileWrite(int n, ban s);
void modify() {
int j = 0;
FILE * fp;
if ((fp = fopen("a.txt", "r")) == NULL) return;
stu s;
ban s;
while (fscanf(fp, "%s %s %s %s %d ", &s[j].no, &s[j].name, &s[j].sex[j],&s[j].passwd, &s[j].balance) == 5) {
j++;
}
@ -80,7 +80,7 @@ void insert() {
scanf("%d", &n);
FILE * fp;
if ((fp = fopen("a.txt", "at")) == NULL) return;
stu s;
ban s;
for (i = 0; i<n; i++) {
printf("\n请输入第%d个用户的卡号", i + 1);
scanf("\n%s", &s[i].no);
@ -91,17 +91,18 @@ void insert() {
printf("\n请输入第%d 个用户的密码:", i + 1);
scanf("%s", &s[i].passwd);
//写入文件
fseek(fp, 0L, SEEK_END);
fprintf(fp, "%s %s %s %s %d \n", s[i].no, s[i].name, s[i].sex,s[i].passwd, s[i].balance = 0);
fclose(fp);
}
printf("添加成功!!!\n");
fclose(fp);
system("pause");
}
void del() {
int j = 0;
FILE * fp, *fp1;
if ((fp = fopen("a.txt", "r")) == NULL) return;
stu s;
ban s;
while (fscanf(fp, "%s %s %s %s %d ", &s[j].no, &s[j].name, &s[j].sex[j],&s[j].passwd, &s[j].balance) == 5) {
j++;
}
@ -138,7 +139,7 @@ void seek() {
int j = 0,flag=0;
FILE * fp;
if ((fp = fopen("a.txt", "r")) == NULL) return;
stu s;
ban s;
while (fscanf(fp, "%s %s %s %s %d", &s[j].no, &s[j].name, &s[j].sex[j], &s[j].passwd, &s[j].balance) == 5) {
j++;
}
@ -148,7 +149,7 @@ void seek() {
lable1:
printf("请输入卡号(输入0返回主菜单)\n");
scanf("%s", &s1);
if(s1=0)
if (strcmp(s1, "0") == 0)
{
return;
}
@ -183,18 +184,19 @@ void save()
{
int j = 0,flag=0;
FILE * fp;
if ((fp = fopen("a.txt", "r")) == NULL) return;
stu s;
if ((fp = fopen("a.txt", "r+")) == NULL) return;
ban s;
while (fscanf(fp, "%s %s %s %s %d", &s[j].no, &s[j].name, &s[j].sex[j], &s[j].passwd, &s[j].balance) == 5) {
j++;
}
n = j;
int i = 0, item,save;
struct Bank *str = s;
int i = 0, item,save,aftersave;
char s1[13], s2[20];
lable1:
printf("请输入卡号(输入0返回主菜单)\n");
scanf("%s", &s1);
if(s1=0)
if (strcmp(s1, "0") == 0)
{
return;
}
@ -205,9 +207,11 @@ int j = 0,flag=0;
if (strcmp(s[i].passwd, s2) == 0) {
printf("请输入您要存款的金额:");
scanf("%d",&save);
fprintf(fp, "%s %s %s %s %d \n", s[i].no, s[i].name, s[i].sex,s[i].passwd, s[i].balance = s[i].balance+save);
printf("存款成功!")
printf("当前余额为%d元",s[i].balance);
s[i].balance = save + s[i].balance;
fileWrite(n, s);
fclose(fp);
printf("存款成功!\n");
printf("当前余额为%d元\n",s[i].balance);
flag = 2;
break;
}
@ -221,11 +225,11 @@ int j = 0,flag=0;
printf("您输入的用户名不存在,请重新输入\n");
goto lable1;
}
fclose(fp);
system("pause");
}
void fileWrite(int n, stu s) {
void fileWrite(int n, ban s) {
FILE *fp1;
int i;
if ((fp1 = fopen("a.txt", "w")) == NULL) return;
@ -233,7 +237,6 @@ int j = 0,flag=0;
fprintf(fp1, "%s %s %s %s %d ", s[i].no, s[i].name, s[i].sex,s[i].passwd, s[i].balance);
}
fclose(fp1);
printf("保存成功!!!\n");
}
/* 界面*/
void menu() {
@ -261,6 +264,7 @@ void menu() {
seek();
break;
case 2:
save();
break;
case 3:
break;

Binary file not shown.
Loading…
Cancel
Save