C语言如何实现ATM机存存折能在取款机取钱吗系统

C语言程序设计报告(模拟ATM取款机)_百度文库
您的浏览器Javascript被禁用,需开启后体验完整功能,
赠送免券下载特权
10W篇文档免费专享
部分付费文档8折起
每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
C语言程序设计报告(模拟ATM取款机)
阅读已结束,下载本文需要
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,同时保存到云知识,更方便管理
加入VIP
还剩42页未读,
定制HR最喜欢的简历
你可能喜欢C语言模拟ATM机源代码码(文件存储) - VC源码 - 文件 - 源码天空
> 文件 > C语言模拟ATM机源代码码(文件存储)
&热门VC源码
C语言模拟ATM机源代码码(文件存储)
资源等级:
上传会员:
资源类别:
文件大小:
原创作者:
发布时间:
网友评分:
5.0分 / 3次
下载次数:
C语言模拟的银行ATM机系统!利用文件存储!每个用户都会被存到user.txt文本中,另外系统生成4个文件(存款记录、取款记录、转账记录、余额)!实现存、取、转、查功能!对密码输入次数进行了限制,错误三次就退出程序!对用户密码进行简单的加密!
&&网友评论(共有8条)
kaonidaye1, 19:23:20
&这就是源码
diyuheixue, 13:07:26
&你用了哪些工具软件,请列举一下,谢谢哦,呵呵。。
NoChinese, 15:18:35
&微软的VC6.0
diyuheixue, 08:52:12
&学习学习!!!
lizhaobomb, 23:31:57
&很好!界面做的不错
wangdawumfc, 00:37:37
&下下载学习学习,谢谢分享
iamyangjy, 20:58:28
&怎么下载呢
Chenying, 10:44:20
&&→&发表我的评论:
*字数限制500个字符(一个汉字占三个字符)
QQ技术交流群:编程乐园
(VB交流群) 3326898(Delphi交流群) (VC交流群)
版权所有 &
保留所有权力【精品】C语言版ATM银行取款机系统源码以及程序设计基础实训_百度文库
您的浏览器Javascript被禁用,需开启后体验完整功能,
赠送免券下载特权
10W篇文档免费专享
部分付费文档8折起
每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
【精品】C语言版ATM银行取款机系统源码以及程序设计基础实训
阅读已结束,下载本文需要
想免费下载本文?
定制HR最喜欢的简历
下载文档到电脑,同时保存到云知识,更方便管理
加入VIP
还剩40页未读,
定制HR最喜欢的简历
你可能喜欢搜索结果部分由C语言实现 ATM机存取款系统
利用结构体和构造函数并且采用输入输出文件实现ATM机系统。主要功能有:
利用三种方法查询、开户、登陆、菜单、取款、修改密码、存款、转账、创建个人信息、输出、删除、增加、退出。是一个功能齐全,完备的ATM机系统。 #include&stdio.h&
#include&string.h&
#include&stdlib.h&
struct per
//定义结构体
char name[20];
char ID[20];
char mima[6];
struct per *
typedef struct person
//定义另一结构体
struct person *
void chaxun(struct per *head);
//各个函数的声明
void kaihu(struct per *head);
void denglu(struct per *head);
void caidan(struct per *head);
void qukuan(struct per *head);
void xgmm(struct per *head);
void cunkuan(struct per *head);
void zhuanzhang(struct per *head);
void chuangjian(struct person **Phead);
void shuchu(struct person *Phead);
void shanchu(struct person **Phead);
void zengjia(struct person **Phead);
void chaxun1(struct person *Phead);
void chaxun2(struct person *Phead);
void chaxun3(struct person *Phead);
void tuichu();
void menu();
/*主函数*/
//////////////////////////////////////////////////
void main()
//choose为定义输入选择的变量
int flag=1;
struct person *Phead=NULL; //Phead为定义二层头指针
struct per *head=NULL;
//head为定义一层头指针
printf("*****************************\n");
printf("**欢迎使用ATM自动取款机系统**\n");
printf("*****************************\n");
printf("——————————————\n");
printf("——————————————\n");
printf("——————————————\n");
前台客户信息查询中心|\n");
printf("——————————————\n");
请选择您的需求
printf("——————————————\n");
scanf("%s",&x);
system("cls");
case '1':system("cls");
kaihu(head);
//调用开户函数
case '2':system("cls");
denglu(head);
//调用登陆函数
case '3':system("cls");
//调用后台菜单函数
while(flag)
system("cls");
//调用后台菜单函数
choose=getchar();
switch(choose)
case '1':chuangjian(&Phead);
shuchu(Phead); //调用后台输出函数
system("pause");
system("cls");
case '2':chaxun1(Phead); //调用后台卡号查询函数
system("pause");
system("cls");
case '3':chaxun2(Phead); //调用后台姓名查询函数
system("pause");
system("cls");
chaxun3(Phead); //调用后台余额查询函数
system("pause");
system("cls");
case '5':shanchu(&Phead); //调用后台删除用户函数
system("pause");
system("cls");
zengjia(&Phead); //调用后台增加用户函数
system("pause");
system("cls");
case '7':shuchu(Phead); //调用后台输出函数函数
system("pause");
system("cls");
case '8':shuchu(Phead);
system("pause");
system("cls");
case '0':flag=0;
printf("The end.\n");
/*开户函数*/
////////////////////////////////////////////////////////
void kaihu(struct per *head)
head=NULL;
//定义文件指针
struct per *p1=NULL,*p2=NULL;
//p1,p2为定义链表指针
p1=(struct per*)malloc(sizeof(struct per));
//开辟内存单元
printf("请输入您的姓名:\n");
//请数据输入链表中
scanf("%s",p1-&name);
printf("请设置您的卡号:\n");
scanf("%s",p1-&ID);
printf("请设置您银行卡密码:\n");
scanf("%s",p1-&mima);
p1-&money=0;
p1-&next=NULL;
printf("您的个人信息为");
printf("姓名:%s \n卡号:%s \n余额:%4d\n",p1-&name,p1-&ID,p1-&money);
if(NULL==head)
//为新用户开辟内存单元
head=(struct per *)malloc(sizeof(struct per));
head-&next=p1;
//进行头插法,将其作为第一个节点
//为新增客户开辟内存单元
for(p2=p2-&next!=NULL;p2=p2-&next); //进行尾插
p2-&next=p1;
if((fp=fopen("save.txt","ab+"))==NULL) //打开文件
printf("cannot poen file\n");
if(fwrite(p1,sizeof(struct per),1,fp)!=1)
//将链表信息写入文件中
printf("file write error\n");
fclose(fp);
printf("\n");
printf("恭喜您开户成功,请登录\n");
system("pause");
system("cls");
denglu(head);
//登陆函数
/////////////////////////////////////////////////////
void denglu(struct per *head)
char d[20];
char mima[20];
//定义文件指针
struct per *p,*q=NULL;
if((fp=fopen("save.txt","rb+"))==NULL)
//打开一个二进制文件,为读方式
printf("不能打开文件\n");
//如不能打开,则结束程序
p=(struct per*)malloc(sizeof(struct per));
//申请空间
while(!feof(fp))
//循环读数据直到文件尾结束
if(1!=fread(p,sizeof(struct per),1,fp))
//如果没读到数据,跳出循环
p-&next=(struct per *)malloc(sizeof(struct per));
//为下一个结点申请空间
//保存当前节点的指针,作为下一结点的前驱
//指针后移,新读入数据链到当前表尾
q-&next=NULL;
//最后一个结点的后继指针为空
fclose(fp);
**********************\n");
***欢迎来都建设银行***\n");
**********************\n");
for(j=1;j&4;j++)
//限制卡号输入的次数的循环
printf("请输入您的卡号\n");
scanf("%s",d);
for(q=q!=NULL;q=q-&next)
//遍历链表
if(strcmp(q-&ID,d)!=0)
//核对账号
//跳出循环
for(i=1;i&4;i++)
//限制密码输入的次数的循环
printf("\n\n请输入您的密码\n");
scanf("%s",mima);
if(strcmp(q-&mima,mima)!=0)
//核对密码
printf("密码不正确。请重新输入密码\n");
system("pause");
system("cls");
//若密码不对,跳出循环
system("cls");
caidan(head);
//调用菜单函数
printf("\n\n\n您输入密码三次错误,谢谢光临\n");
system("pause");
system("cls");
printf("\n\n\n您输入的卡号有误,请重试\n");
system("pause");
system("cls");
printf("您的卡号三次输入错误,谢谢使用\n");
//银行菜单函数
/////////////////////////////////////////////////////////////
void caidan(struct per *head)
head=NULL;
//i为客户选择输入的变量
printf("请选择您需要的业务\n");
//银行业务菜单
printf("*********************************\n");
printf("**
printf("*********************************\n");
printf("**
4 修改密码**\n");
printf("*********************************\n");
printf("**
printf("*********************************\n");
scanf("%d",&i);
if(i&6||i&0)
case 1:qukuan(head);
//调用银行取款函数
system("pause");
system("cls");
case 2:system("cls");
chaxun(head);
//调用银行查询函数
case 3:system("cls");
zhuanzhang(head);
//调用银行转账函数
case 4:system("cls");
xgmm(head);
//调用银行修改密码函数
case 5:system("cls");
cunkuan(head);
//调用银行存款函数
case 6:system("cls");
//调用银行退出函数
printf("您的输入有误\n");
system("pause");
system("cls");
//银行取款函数
//////////////////////////////////////////////////
void qukuan(struct per *head)
head=NULL;
//head为链表头指针
//定义文件指针
struct per *p,*q=NULL;
if((fp=fopen("save.txt","rb+"))==NULL) //打开一个二进制文件,为读方式
printf("不能打开文件\n");
//如不能打开,则结束程序
p=(struct per*)malloc(sizeof(struct per));
//申请空间
while(!feof(fp))
//循环读数据直到文件尾结束
if(1!=fread(p,sizeof(struct per),1,fp))
//如果没有读到数据,跳出循环
p-&next=(struct per *)malloc(sizeof(struct per));
//为下一个结点申请空间
//保存当前结点的指针,作为下一个结点的前驱
//指针后移,新读入数据链到当前表尾
q-&next=NULL;
//最后一个结点的后继指针为空
fclose(fp);
system("cls");
printf("************************************\n");
printf("**
printf("************************************\n");
printf("**
printf("************************************\n");
printf("**
printf("************************************\n");
printf("请按要求选择您要取款的金额\n");
scanf("%d",&i);
if(i&6||i&=0)
//限制输入范围
printf("对不起,您的输入有误\n\n");
//对应选项乘以一百为取款金额
if(i&q-&money)
printf("对不起,您的金额不足\n");
system("pause");
system("cls");
caidan(head);
//调用取款机菜单函数
q-&money-=i;
//对金额进行处理
if((fp=fopen("save.txt","wb+"))==NULL)
//打开文件
printf("cannot open file\n");
if(fwrite(q,sizeof(struct per),1,fp)!=1) //将修改的信息重新写入文件
printf("file write error\n");
printf("您已经成功取走%d元\n");
q-&next=NULL;
fclose(fp);
//关闭文件
//银行转账函数
/////////////////////////////////////////////
void zhuanzhang(struct per *head)
head=NULL;
//定义文件指针
struct per *p,*q=NULL;
if((fp=fopen("save.txt","rb+"))==NULL)
//打开一个二进制文件,为读方式
printf("不能打开文件\n");
//如不能打开,则结束程序
p=(struct per*)malloc(sizeof(struct per));
//申请空间
while(!feof(fp))
//循环读数据直到文件尾结束
if(1!=fread(p,sizeof(struct per),1,fp))
//如果没读到数据,跳出循环
p-&next=(struct per *)malloc(sizeof(struct per));
//为下一个结点申请空间
//保存当前结点的指针,作为下一个结点的前驱
//指针后移,新读入数据链到当前表尾
q-&next=NULL;
//最后一个结点的后继指针为空
fclose(fp);
int i,j,k;
printf("请输入帐号号码\n");
scanf("%d",&i);
printf("请再次输入帐号号码\n");
//核对卡号
scanf("%d",&j);
printf("两次账号不同,请重新输入\n");
zhuanzhang(head);
system("cls");
printf("************************************\n");
printf("**
printf("************************************\n");
printf("**
printf("************************************\n");
printf("**
printf("************************************\n");
printf("请输入转账金额\n");
scanf("%d",&k);
if(k&6||k&=0)
printf("对不起,您的输入有误\n\n");
if(k&q-&money)
//对余额进行判断
printf("对不起,您的余额不足\n");
system("pause");
system("cls");
caidan(head);
printf("您已成功转账%d元\n",k);
q-&money-=k;
if((fp=fopen("save.txt","wb+"))==NULL)
printf("cannot open file\n");
if(fwrite(q,sizeof(per),1,fp)!=1)
//将数据重新写入文件
printf("file write error\n");
q-&next=NULL;
fclose(fp);
system("pause");
system("cls");
//银行查询函数
/////////////////////////////////////////////////
void chaxun(struct per *head)
head=NULL;
//链表头指针
//定义文件指针
struct per *p,*q=NULL;
if((fp=fopen("save.txt","rb+"))==NULL)
//打开一个二进制文件,为读方式
printf("不能打开文件\n");
//如不能打开,则结束程序
p=(struct per*)malloc(sizeof(struct per));
//申请空间
while(!feof(fp))
//循环读数据直到文件尾结束
if(1!=fread(p,sizeof(struct per),1,fp))
//如果没读到数据,跳出循环
p-&next=(struct per *)malloc(sizeof(struct per));
//为下一个结点申请空间
//保存当前结点的指针,作为下一个结点的前驱
//指针后移,新读入数据链到当前表尾
q-&next=NULL;
//最后一个结点的后继指针为空
fclose(fp);
printf("您卡上原有余额%d元\n\n",q-&money);
system("pause");
system("cls");
//银行修改密码函数
//////////////////////////////////////////////////
void xgmm(struct per *head)
head=NULL;
//链表头指针
char mima[20];
//定义文件指针
struct per *p,*q=NULL;
if((fp=fopen("save.txt","rb+"))==NULL)
//打开一个二进制文件,为读方式
printf("不能打开文件\n");
//如不能打开,则结束程序
p=(struct per*)malloc(sizeof(struct per));
//申请空间
while(!feof(fp))
//循环读数据直到文件尾结束
if(1!=fread(p,sizeof(struct per),1,fp))
//如果没读到数据,跳出循环
p-&next=(struct per *)malloc(sizeof(struct per));
//为下一个结点申请空间
//保存当前结点的指针,作为下一个结点的前驱
//指针后移,新读入数据链到当前表尾
q-&next=NULL;
//最后一个结点的后继指针为空
fclose(fp);
printf("请输入您的原密码\n");
scanf("%s",mima);
if(strcmp(q-&mima,mima)==0)
//核对密码
printf("密码正确\n");
printf("请输入您的新密码:\n");
scanf("%s",q-&mima);
if((fp=fopen("save.txt","wb+"))==NULL)
//文件头指针
printf("cannot open file\n");
if(fwrite(q,sizeof(struct per),1,fp)!=1)
//将修改的密码重新写入文件
printf("file write error\n");
fclose(fp);
printf("修改密码成功\n\n\n\n\n");
printf("您输入的密码与原密码不同\n");
system("pause");
q-&next=NULL;
//银行存款函数
////////////////////////////////////
void cunkuan(struct per *head)
head=NULL;
//链表头指针
//定义文件指针
struct per *p,*q=NULL;
if((fp=fopen("save.txt","rb+"))==NULL)
//打开一个二进制文件,为读方式
printf("不能打开文件\n");
//如不能打开,则结束程序
p=(struct per*)malloc(sizeof(struct per));
//申请空间
while(!feof(fp))
//循环读数据直到文件尾结束
if(1!=fread(p,sizeof(struct per),1,fp))
//如果没读到数据,跳出循环
p-&next=(struct per *)malloc(sizeof(struct per));
//为下一个结点申请空间
//保存当前结点的指针,作为下一个结点的前驱
//指针后移,新读入数据链到当前表尾
q-&next=NULL;
//最后一个结点的后继指针为空
fclose(fp);
system("cls");
printf("您卡上原有余额%d元\n",q-&money);
printf("************************************\n");
printf("**
printf("************************************\n");
printf("**
printf("************************************\n");
printf("**
printf("************************************\n");
printf("请选择您要存入的余额\n");
scanf("%d",&i);
if(i&6||i&=0)
printf("对不起,您的输入有误\n\n");
q-&money+=i;
if((fp=fopen("save.txt","wb+"))==NULL)
//打开文件
printf("cannot open file\n");
if(fwrite(q,sizeof(struct per),1,fp)!=1)
//将修改的密码重新写入文件
printf("file write error\n");
printf("您已经成功存取%d元\n",i);
q-&next=NULL;
fclose(fp);
system("pause");
system("cls");
//退出银行函数
///////////////////////////////////////////
void tuichu()
printf("谢谢使用\n");
//后台运行菜单函数
///////////////////////////////////////////////////////
void menu()
printf("****************欢迎来到建设银行取款机系统****************\n\n\n\n");
printf("**************************************************\n");
printf("**** 1 建立信息并显示
2 卡号查询信息 ****\n");
printf("**************************************************\n");
printf("**** 3 姓名查询信息
4 余额查询信息 ****\n");
printf("**************************************************\n");
printf("**** 5 删除某卡号信息
6 增加新的用户 ****\n");
printf("**************************************************\n");
printf("**** 7 按余额降序输出
printf("**************************************************\n");
printf("**** 0 退出
printf("**************************************************\n");
printf("请选择您需要的业务\n\n");
//后台运行创建链表函数
////////////////////////////////////////////////////
void chuangjian(struct person **Phead)
//*(*Phead)为指向结构体指针的地址
struct person *p,*t;
//定义操作指针
char n[20];
char a[20];
if(*Phead) *Phead=NULL;
printf("请输入卡号 姓名 余额 (若要结束请输入三个为零)\n");
printf("请输入卡号\n");
scanf("%s",n);
printf("请输入姓名\n");
scanf("%s",a);
printf("请输入预存金额\n");
scanf("%d",&s);
p=(L *)malloc(sizeof(L));
//将信息输入链表中
strcpy(p-&kehu.ID,n);
strcpy(p-&kehu.name,a);
//将指针重新指向头指针
printf("请输入卡号\n");
scanf("%s",n);
printf("请输入姓名\n");
scanf("%s",a);
printf("请输入预存金额\n");
scanf("%d",&s);
//将p的值赋给t,p又可以储存下一个结点
p=(L *)malloc(sizeof(L));
//为新结点开辟新的内存
strcpy(p-&kehu.ID,n);
strcpy(p-&kehu.name,a);
p-&kehu.money=s;
p-&next=NULL;
t-&next=p;
//将p的值接在t(即上一个结点的后面)
printf("请输入卡号\n");
scanf("%s",n);
printf("请输入姓名\n");
scanf("%s",a);
printf("请输入预存金额\n");
scanf("%d",&s);
//后台运行输出链表函数
/////////////////////////////////////////////
void shuchu(struct person *Phead)
printf("\n\n");
if(NULL==Phead)
printf("没有客户信息可输出!\n");
//若头指针指向空,则没有客户信息
while(Phead)
//遍历输出链表中所有客户信息
printf("卡号:%s\n姓名:\n余额:%d\n",Phead-&kehu.ID,Phead-&kehu.name,Phead-&kehu.money);
Phead=Phead-&
printf("\n\n");
//后台运行卡号查询函数
///////////////////////////////////////////////////
void chaxun1(struct person*Phead)
char m[20];
//定义输入查找客户卡号的变量
if(NULL==Phead)
//若头指针向空,则没有客户信息
printf("没有客户信息可查询!\n");
printf("请输入要查询的客户卡号:\n");
scanf("%s",m);
while(NULL!=Phead&&strcmp(Phead-&kehu.ID,m)!=0)
//在链表中遍历寻找中,直到链表存在并且卡号核对无误
Phead=Phead-&
if(Phead==NULL)
//若指针指最后指向空,则没有客户信息
printf("对不起,没有该用户!\n");
printf("卡号:%s\n姓名:\n余额:%d\n",Phead-&kehu.ID,Phead-&kehu.name,Phead-&kehu.money);
//若找到,则输出客户信息
//后台运行姓名查询函数
/////////////////////////////////////////////////////
void chaxun2(struct person *Phead)
char m[20];
//定义输入查找客户卡号的变量
if(NULL==Phead)
//若头指针向空,则没有客户信息
printf("没有客户信息可查询!\n");
printf("请输入要查询的客户姓名:\n");
scanf("%s",m);
while(NULL!=Phead&&strcmp(Phead-&kehu.name,m)!=0)
//在链表中遍历寻找中,直到链表存在并且姓名核对无误
Phead=Phead-&
if(Phead==NULL)
//若指针指最后指向空,则没有客户信息
printf("对不起,没有该用户!\n");
printf("卡号:%s\n姓名:\n余额:%d\n",Phead-&kehu.ID,Phead-&kehu.name,Phead-&kehu.money);
//若找到,则输出客户信息
//后台运行余额查询函数
/////////////////////////////////////////////////////
void chaxun3(struct person *Phead)
//定义输入查找客户余额的变量
if(NULL==Phead)
//若头指针向空,则没有客户信息
printf("没有客户信息可查询!\n");
printf("请输入要查询的客户信息的余额:\n");
scanf("%ld",&x);
while(NULL!=Phead&&Phead-&kehu.money!=x)
//在链表中遍历寻找中,直到链表存在并且余额核对无误,继续寻找
Phead=Phead-&
if(Phead==NULL)
//若指针指最后指向空,则没有客户信息
printf("对不起,没有该用户!\n");
printf("该客户的信息为\n");
printf("卡号:%s\n姓名:\n余额:%d\n",Phead-&kehu.ID,Phead-&kehu.name,Phead-&kehu.money);
//若找到,则输出客户信息
//后台运行删除客户信息函数
///////////////////////////////////////////////////
void shanchu(struct person **Phead)
//*(*Phead)为指向结构体指针的地址
char k[20];
//定义输入查找客户姓名卡号的变量
struct person *p=*Phead,*t;
if(NULL==(*Phead))
//若指针最后指向空,则没有客户信息
printf("没有客户信息可删除!\n");
printf("请输入要删除的客户卡号:\n");
scanf("%s",k);
if(p-&kehu.ID==k)
//若第一个客户就是,则让头指针指向下一个结点
*Phead=(*Phead)-&next,free(p);
while(NULL==p-&next&&p-&next-&kehu.ID!=k)
//遍历寻找,核对客户卡号
//当p-&next没指向空,并且客户的卡号还没找到,则继续寻找
if(p-&next==NULL)
printf("对不起,没有该客户!\n");
//如果找到,则把p-&next的值赋给t
p-&next=p-&next-&
//后台运行增加用户信息函数
////////////////////////////////////////////////////////////
void zengjia(struct person **Phead)
//*(*Phead) 为指向结构体指针的地址
char n[20];
//定义输入增加客户卡号的变量
char a[20];
//定义输入增加客户姓名的变量
L *p,*t,*k;
//定义操作指针变量
printf("请输入要插入的客户信息\n");
printf("请输入卡号\n");
scanf("%s",&n);
printf("请输入姓名\n");
scanf("%s",a);
printf("请输入预存金额\n");
scanf("%d",&s);
p=(L *)malloc(sizeof(L));
//开辟空间
strcpy(p-&kehu.ID,a);
//将新的客户信息写入链表
p-&kehu.money=s;
strcpy(p-&kehu.name,n);
if(NULL==(*Phead))
//如果是空链表,则把新客户信息作为第一个结点
(*Phead)-&next=NULL;
p-&next=(*Phead);
(*Phead)=p;
没有更多推荐了,
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!

我要回帖

更多关于 存款人死亡后怎么取款 的文章

 

随机推荐