写在前面:这是我大一时的课程设计项目的源代码,供大家学习交流。这套代码主要实现的功能是基于C语言模拟ATM机存取款的一些简单操作。本文字数:14938。
以下是基本要求:
- 可以进行账户的注册与登陆;
- 可以进行存款和取款;
- 可以修改密码和注销登陆;
- 可以进行转账;
- 可以进行余额查询。
还有一些是我自己添加的额外功能(需要互联网支持以及相关接口):
- 重要操作(注册账户时/登陆/注销/存款/取款/转账/注销时)发送短信通知;
- 对重要操作(注册账户时/登陆/注销/存款/取款/转账/注销时)生成操作日志;
- 主页面显示账户余额;
- 程序启动时有欢迎动画(logo.bat),退出时有结束动画;
- 界面切换时有动画效果(逐字打印效果);
- 程序启动时有自检程序。
*短信接口使用的是云片网。使用C#的SDK进行修改,发送短信时生成短信内容至txt,然后调用编写好的.exe可执行文件直接进行发送。SDK可在云片网官网API开发者文档进行下载。有关于短信接口SDK/API可查看《文章占位》。由于我编写好的exe文件中包含重要信息,所以就不放出来了。
#include <stdio.h>
#include <windows.h>
#include <stdlib.h>
#include <string.h>
#include <conio.h>
#include <time.h>
#include <io.h>
void Load(int n);
int Welcome();
int SignIn();
int SignUp();
int Deposit();
int Withdraw();
int Check();
int Transfer();
int Reset();
int Logout();
int Quit(int n);
int PrintLog(char n,int money,char account[]);
void ZZPrint(char *a, int t);
struct SATM
{
char username[15];
char password[6];
int account[15];
double money;
char phonenumber[11];
int state;
}Guest;
struct Message
{
char phonenumber[11];
char text[100];
}Msg;
struct SATM t;
struct SATM t1;
int status, count = 0;
int No, ds;
FILE *fp; FILE *log; FILE *temp; FILE *other;
void Inputpassword(char [])//密码加密
{
i = 0;
char ch;
while (1)
{
ch = getch();
if (ch != '\r')//回车?
{
if (ch != '\b')//退格?
{
mima[i] = ch;
i++;
printf("*");
}
else
{
if (i > 0)//保证不会删除前面的字
{
i--;
printf("\b \b");//退格,删除
}
}
}
else
{
break;
}
}
mima[i] = '\0';
}
void main()
{
int n = 0;
status = -1;
char FunNo;
system("cls");
ZZPrint("欢迎!\n", 50);
system("cls");
printf("\n");
if (!access("D://SATM", 0))
{
system("d:\\SATM\\logo.bat");
}
else mkdir("D:\\SATM");
Sleep(100);
ZZPrint("\nSATM文件夹存在...\n", 30);
other = fopen("D:\\SATM\\data.txt", "rb+");
if (other == NULL)
ZZPrint("\n初始化中...\n", 50);
ZZPrint("\n正在检查外部组件...\n", 30);
other = fopen("D:\\SATM\\MsgSender.exe", "rb+");
if (other != NULL)
{
Sleep(100);
printf("MsgSender.exe\n完成!\n");
fclose(other);
ZZPrint("\n正在检查dll文件...\n", 30);
other = fopen("D:\\SATM\\Newtonsoft.Json.dll", "rb+");
if (other != NULL)
{
Sleep(100);
printf("Newtonsoft.Json.dll(1/2)\n");
fclose(other);
other = fopen("D:\\SATM\\Yunpian.dll", "rb+");
if (other != NULL)
{
Sleep(100);
printf("Yunpian.dll(2/2)\n");
fclose(other);
}
else n = -1;
}
else n = -1;
}
else n = -1;
system("color 2F");
ZZPrint("\n程序自检完成...", 30);
if (n==-1)
{
system("color 4F");
printf("\n文件缺失,请检查必要文件!\n");
printf("\n按任意键退出!");
getch();
exit(0);
}
Sleep(500);
system("cls");
printf("正在进入.");
Load(1);
system("cls");
while (status == -1)
{
system("color F1");//配色
printf("\n\n\n\n\n\n\t\t\t\t\t\t");
ZZPrint("欢迎进入S-ATM系统", 80);
printf("\n\n\n\t\t\t\t\t----------------------------------\n");
Sleep(100);
other = fopen("D:\\SATM\\data.txt", "rb+");
if (other != NULL)
{
printf("\n\n\t\t\t\t\t\t [I]登陆S-ATM账户\n");
Sleep(100);
}
printf("\n\n\t\t\t\t\t\t [U]注册S-ATM账户\n");
Sleep(100);
printf("\n\n\t\t\t\t\t\t [Q]退出S-ATM系统\n");
Sleep(500);
printf("\n\n\n\t\t\t\t\t");
ZZPrint("请输入功能序号(不区分大小写):", 25);
fflush(stdin);//清楚缓冲区回车符
scanf("%s", &FunNo);
switch (FunNo)
{
case 'i':
case 'I':
if (other != NULL)
{
SignIn(); break;
}
case 'u':
case 'U':
SignUp(); break;
case 'q':
case 'Q':Quit(1000); break;
default:
system("color 74");
printf("\n\t\t\t\t\t输入有误请重新输入,按任意键继续");
getch();
break;
}
system("cls");
}
}
void Load(int n)//加载中......
{
switch (n)
{
case 1:
Sleep(100);
printf(".");
printf("");
printf(".");
Sleep(100);
printf(".");
Sleep(90);
printf(".");
Sleep(90);
printf(".");
Sleep(80);
printf(".");
Sleep(80);
printf(".");
Sleep(70);
printf(".");
Sleep(60);
printf(".");
Sleep(50);
printf(".");
Sleep(50);
printf(".");
Sleep(40);
printf(".");
Sleep(40);
printf(".");
Sleep(30);
printf(".");
Sleep(20);
printf(".");
Sleep(10);
printf(".");
break;
case 2:Sleep(50);
printf(".");
Sleep(50);
printf(".");
Sleep(40);
printf(".");
Sleep(40);
printf(".");
Sleep(30);
printf(".");
Sleep(20);
printf(".");
Sleep(10);
Sleep(500);
system("cls");
break;
}
}
int Welcome()//欢迎界面
{
int i;
char ServicesNo;
system("cls");
while (status == 0)
{
system("color F5");
printf("登陆成功!");
printf("账号:%s,用户名:%s,当前余额:¥%.2lf", t.account, t.username, t.money);
printf("\n\n\n\t\t\t\t\t\t");
ZZPrint(" [C]查询服务", 10);
Sleep(10);
printf("\n\n\n\t\t\t\t\t\t");
ZZPrint(" [D]存款服务", 10);
Sleep(10);
printf("\n\n\n\t\t\t\t\t\t");
ZZPrint(" [W]取款服务", 10);
Sleep(10);
printf("\n\n\n\t\t\t\t\t\t");
ZZPrint(" [T]转账服务", 10);
Sleep(10);
printf("\n\n\n\t\t\t\t\t\t");
ZZPrint(" [R]修改密码", 10);
Sleep(10);
printf("\n\n\n\t\t\t\t\t\t");
ZZPrint(" [L]注销登陆", 10);
Sleep(10);
printf("\n\n\n\t\t\t\t\t\t");
ZZPrint(" [Q]退出系统", 10);
ZZPrint("\n\n\n\t\t\t\t\t-------------------------------", 5);
ZZPrint("\n\t\t\t\t\t请输入功能序号(不区分大小写):", 15);
fflush(stdin);//清楚缓冲区回车符
scanf("%s", &ServicesNo);
switch (ServicesNo)
{
case 'c':
case 'C':
Check(); break;
case 'd':
case 'D':
Deposit(); break;
case 'w':
case 'W':
Withdraw(); break;
case 't':
case 'T':
Transfer(); break;
case 'r':
case 'R':
Reset(); break;
case 'l':
case 'L':
Logout(); break;
case 'q':
case 'Q':
Quit(1000); break;
default:
system("color 74");
printf("\n\t\t\t\t\t输入有误请重新输入,按任意键继续");
getch();
break;
}
system("cls");
}
printf("\n\t\t\t\t\t非法登陆!即将退出!");
Logout();
}
int SignIn()//登陆界面
{
int i = 0, k = 0;
char account[15];
char password[6];
fp = fopen("D:\\SATM\\data.txt", "rb+");
if (fp == NULL)
{
printf("打开失败,数据库文件损坏!");
return;
}
system("cls");
system("color F3");
printf("正在进入登陆界面.");
Load(2);
fflush(stdin);
printf("\n\n\t\t\t\t\t\tS-ATM账号:");
scanf("%s", &account[0]);
while (fread(&t, sizeof(t), 1, fp))
{
if (strcmp(account, t.account) == 0)
{
k = 1;
break;
}
}
if (k == 1)
{
if (t.state == 0)
{
printf("\n\t\t\t\t\t账户被冻结,无法登陆!");
Sleep(500);
getch();
SignIn();
}
printf("\n\n\t\t\t\t\t\tS-ATM账户密码:");
Inputpassword(password);
while (strcmp(password, t.password) != 0)
{
if (i++ >= 2)
{
t.state = 0;
printf("\n\n\t\t\t\t\t密码错误次数过多,冻结账户!");
fseek(fp, -sizeof(t), 1);
fwrite(&t, sizeof(t), 1, fp);
Sleep(1000);
SignIn();
}
printf("\n\n\t\t\t\t\t密码错误请重新输入");
printf("\n\n\t\t\t\t\t按ESC返回上一级");
if (getch() == 27) main();
fflush(stdin);
Sleep(100);
system("cls");
printf("\n\n\t\t\t\t\t\tS-ATM账号:%s", t.account);
printf("\n\n\t\t\t\t\t\tS-ATM账户密码:");
Inputpassword(password);
}
}
if (strcmp(password, t.password) == 0)
{
printf("\n\n\t\t\t\t\t\t");
ZZPrint("登陆成功,即将进入功能界面", 50);
PrintLog('I',0,t.account);
status = 0;
Welcome();
}
if (k == 0);
{
printf("\n\t\t\t\t\t账号不存在,请重新输入!");
printf("\n\n\t\t\t\t\t按ESC返回上一级");
if (getch() == 27) main();
SignIn();
}
getch();
return 0;
}
int SignUp()//注册界面
{
system("cls");
printf("正在进入注册界面.");
Load(2);
char Repassword[6];
fp = fopen("D:\\SATM\\data.txt", "ab+");
if (fp == NULL)
{
printf("打开失败,数据库文件损坏!");
return;
}
fflush(stdin);
printf("\n\n\t\t\t\t\tS-ATM用户名(小于15个字符):");
scanf("%s", &Guest.username[0]);
printf("\n\n\t\t\t\t\t设置您的S-ATM账号(纯数字):");
scanf("%s", &Guest.account[0]);
while (fread(&t, sizeof(t), 1, fp))
{
if (strcmp(Guest.account, t.account) == 0)
{
printf("\n\t\t\t\t\t账号重复请重新输入!");
getch();
SignUp();
break;
}
}
fseek(fp, 0, 2);
printf("\n\n\t\t\t\t\tS-ATM用户手机号:");
scanf("%s", &Guest.phonenumber[0]);
printf("\n\n\t\t\t\t\tS-ATM账户密码(6位):");
Inputpassword(Guest.password);
printf("\n\n\t\t\t\t\t再次输入您的密码:");
Inputpassword(Repassword);
if (strlen(Guest.password) == 6 && strlen(Repassword) == 6)
{
if (strcmp(Guest.password, Repassword) == 0)
{
printf("\n\n\t\t\t\t\t");
system("color F1");
Guest.money = 0;
Guest.state = 1;
fwrite(&Guest, sizeof(struct SATM), 1, fp);
ZZPrint("注册成功,为您跳转至登陆界面", 50);
{//发送短信
temp = fopen("d:\\SATM\\Msg.txt", "ab+");
strcpy(Msg.phonenumber, Guest.phonenumber);
strcat(Msg.text, "【ATM程序设计】亲爱的");
strcat(Msg.text, Guest.username);
strcat(Msg.text, ",欢迎使用SATM系统。");
fseek(temp, -sizeof(Msg), 1);
fwrite(&Msg, sizeof(Msg), 1, temp);
fclose(temp);
system("d:\\SATM\\MsgSender.exe");//调用外部程序
}
{//保存日志
PrintLog('U',0,Guest.account);
}
fclose(fp);
count++;
Sleep(200);
SignIn();
}
else
printf("\n\n\t\t\t\t\t两次密码不同,请重新输入");
printf("\n\n\t\t\t\t\t按ESC返回上一级");
if (getch() == 27) main() ;
SignUp();
}
else
{
printf("\n\n\t\t\t\t\t密码格式错误");
printf("\n\n\t\t\t\t\t按ESC返回上一级");
if (getch() == 27) main();
SignUp();
}
return 0;
}
int Deposit()//存款界面
{
int money;
system("cls");
ZZPrint("欢迎使用S-ATM存款服务", 50);
ZZPrint("\n请输入存款金额:", 50);
fflush(stdin);
scanf("%d", &money);
if (money > 0)
{
ZZPrint("\n请确认存款金额:", 50);
printf("%d", money);
ZZPrint("\n按任意键继续...", 50);
getch();
t.money += money;
fseek(fp, -sizeof(t), 1);
fwrite(&t, sizeof(t), 1, fp);
ZZPrint("\n成功!当前账户余额为:", 50);
PrintLog('D',money,t.account);
printf("%.2lf", t.money);
char nowtime[19];
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
sprintf(nowtime, "%02d:%02d:%02d", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
temp = fopen("d:\\SATM\\Msg.txt", "ab+");
strcpy(Msg.phonenumber, t.phonenumber);
strcat(Msg.text, "【ATM程序设计】尊敬的");
strcat(Msg.text, t.username);
strcat(Msg.text, ",你的账户于");
strcat(Msg.text, nowtime);
strcat(Msg.text, "成功");
strcat(Msg.text, "存入");
sprintf(Msg.text, "%s%d", Msg.text, money);
strcat(Msg.text, "元,感谢您的使用。");
fseek(temp, -sizeof(Msg), 1);
fwrite(&Msg, sizeof(Msg), 1, temp);
fclose(temp);
system("d:\\SATM\\MsgSender.exe");
getch();
return 0;
}
else
{
ZZPrint("\n存款金额有误!请重新输入!", 50);
Sleep(500);
Deposit();
}
}
int Withdraw()//取款界面
{
int money;
system("cls");
ZZPrint("欢迎使用S-ATM取款服务", 50);
ZZPrint("\n请输入取款金额:", 50);
fflush(stdin);
scanf("%d", &money);
ZZPrint("\n请确认取款金额:", 50);
printf("%d", money);
ZZPrint("\n按任意键继续...", 50);
getch();
if (money > 0)
{
if (t.money >= money)
{
t.money -= money;
fseek(fp, -sizeof(t), 1);
fwrite(&t, sizeof(t), 1, fp);
ZZPrint("\n取款成功!当前账户余额为:", 50);
PrintLog('W', money, t.account);
printf("%.2lf", t.money);
char nowtime[19];
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
sprintf(nowtime, "%02d:%02d:%02d", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
temp = fopen("d:\\SATM\\Msg.txt", "ab+");
strcpy(Msg.phonenumber, t.phonenumber);
strcat(Msg.text, "【ATM程序设计】尊敬的");
strcat(Msg.text, t.username);
strcat(Msg.text, ",你的账户于");
strcat(Msg.text, nowtime);
strcat(Msg.text, "成功");
strcat(Msg.text, "取出");
sprintf(Msg.text, "%s%d", Msg.text, money);
strcat(Msg.text, "元,感谢您的使用。");
printf("%s", Msg.text);
fseek(temp, -sizeof(Msg), 1);
fwrite(&Msg, sizeof(Msg), 1, temp);
fclose(temp);
system("d:\\SATM\\MsgSender.exe");
}
else
printf("余额不足,当前余额为%.2lf", t.money);
}
printf("输入的金额有误,请重新输入!" );
getch();
return 0;
}
int Check()//查询界面
{
system("cls");
printf("账号:%s,用户名:%s,当前余额:¥%.2lf,手机号为:%s,用户状态正常", t.account, t.username, t.money, t.phonenumber);
ZZPrint("\n按任意键查看操作日志",50);
getch();
char *Finame[33];
sprintf(Finame, "%s_%s%s", "D:\\SATM\\log", t.account, ".txt");
system(Finame);
getch();
return 0;
}
int Transfer()//转账
{
char Destaccount[15];
int DestNo, money;
int k = 0;
ds = ftell(fp);
system("cls");
ZZPrint("欢迎使用S-ATM转账服务", 50);
ZZPrint("\n请输入目标账号:", 50);
fflush(stdin);
scanf("%s", &Destaccount[0]);
rewind(fp);
while (fread(&t1, sizeof(t1), 1, fp)==1)
{
if (strcmp(Destaccount, t1.account) == 0)
{
k = 1;
break;
}
}
if (k == 0)
{
ZZPrint("\n该账户无效,请重新输入", 50);
printf("\n\n\t\t\t\t\t\t按ESC返回上一级");
if (getch() == 27) Welcome();
Transfer();
}
ZZPrint("\n请输入转账金额:", 50);
scanf("%d", &money);
ZZPrint("\n请确认目标账户持有人:", 50);
printf("%s", t1.username);
getch();
if (money > t.money)
{
ZZPrint("\n转账失败,余额不足!", 50);
printf("\n\n\t\t\t\t\t\t按ESC返回上一级");
if (getch() == 27) Welcome();
}
else
{
t.money -= money;
t1.money += money;
fseek(fp, -sizeof(t1), 1);
fwrite(&t1, sizeof(t1), 1, fp);
fseek(fp, ds-sizeof(t), 0);
fwrite(&t, sizeof(t), 1, fp);
fclose(fp);
ZZPrint("\n转账成功,当前余额:", 50);
PrintLog('T', money, t1.account);
printf("%.2lf", t.money);
char nowtime[19];
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
sprintf(nowtime, "%02d:%02d:%02d", timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
temp = fopen("d:\\SATM\\Msg.txt", "ab+");
strcpy(Msg.phonenumber, t.phonenumber);
strcat(Msg.text, "【ATM程序设计】尊敬的");
strcat(Msg.text, t.username);
strcat(Msg.text, ",你的账户于");
strcat(Msg.text, nowtime);
strcat(Msg.text, "成功向");
strcat(Msg.text, t1.username);
strcat(Msg.text, "转账");
sprintf(Msg.text, "%s%d", Msg.text, money);
strcat(Msg.text, "元,感谢您的使用。");
fseek(temp, -sizeof(Msg), 1);
fwrite(&Msg, sizeof(Msg), 1, temp);
fclose(temp);
system("d:\\SATM\\MsgSender.exe");
temp = fopen("d:\\SATM\\Msg.txt", "ab+");
strcpy(Msg.phonenumber, t1.phonenumber);
strcat(Msg.text, "【ATM程序设计】尊敬的");
strcat(Msg.text, t1.username);
strcat(Msg.text, ",你的账户于");
strcat(Msg.text, nowtime);
strcat(Msg.text, "成功收到来自");
strcat(Msg.text, t.username);
strcat(Msg.text, "的转账");
sprintf(Msg.text, "%s%d", Msg.text, money);
strcat(Msg.text, "元,感谢您的使用。");
fseek(temp, -sizeof(Msg), 1);
fwrite(&Msg, sizeof(Msg), 1, temp);
fclose(temp);
system("d:\\SATM\\MsgSender.exe");
printf("\n\n\t\t\t\t\t\t\t按ESC返回上一级");
if (getch() == 27) Welcome();
}
Welcome();
return 0;
}
int Reset()//修改密码
{
char NewPass[6];
char OldPass[6];
system("cls");
ZZPrint("欢迎使用S-ATM密码修改服务", 50);
ZZPrint("\n请输入原密码:", 50);
fflush(stdin);
Inputpassword(OldPass);
if (strcmp(OldPass, t.password) == 0)
{
ZZPrint("密码验证成功", 50);
ZZPrint("\n请输入新密码:", 50);
Inputpassword(NewPass);
ZZPrint("\n请确认新密码:", 50);
printf("%s", NewPass);
ZZPrint("\n按任意键继续...", 50);
getch();
strcpy(t.password, NewPass);
fseek(fp, -sizeof(t), 1);
fwrite(&t, sizeof(t), 1, fp);
ZZPrint("\n密码修改完成,请重新登陆!", 50);
PrintLog('R', 0, t.account);
Sleep(1000);
Logout();
}
else
ZZPrint("\n密码验证失败,请重新输入", 50);
printf("\n\n\t\t\t\t\t按ESC返回上一级");
if (getch() == 27) Welcome();
Reset();
return 0;
}
int Logout()//注销
{
PrintLog('L', 0, t.account);
fclose(fp);
status = -1;
main();
return 0;
}
int PrintLog(char n, int money, char account[])//记录日志
{
char action[100] = {""};
char *Finame[33];
sprintf(Finame, "%s_%s%s", "D:\\SATM\\log",t.account,".txt");
char *nowtime[19];
time_t rawtime;
struct tm * timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);
sprintf(nowtime, "%4d-%02d-%02d %02d:%02d:%02d", timeinfo->tm_year + 1900, timeinfo->tm_mon + 1 ,timeinfo->tm_mday, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec);
switch (n)
{
case 'I':
{
sprintf(Finame, "%s_%s%s", "D:\\SATM\\log", t.account, ".txt");
log = fopen(Finame, "ab+");
fseek(log, 0, 2);
sprintf(action,"于%s成功登陆。",nowtime);
fwrite(&action, sizeof(action), 1, log);
fprintf(log, "\r\n");
fclose(log);
break;
}
case 'U':
{
sprintf(Finame, "%s_%s%s", "D:\\SATM\\log",account, ".txt");
log = fopen(Finame, "ab+");
sprintf(action, "于%s成功注册。", nowtime);
fseek(log, 0, 2);
fwrite(&action, sizeof(action), 1, log);
fprintf(log, "\r\n");
fclose(log);
break;
}
case 'D':
{
sprintf(Finame, "%s_%s%s", "D:\\SATM\\log", t.account, ".txt");
log = fopen(Finame, "ab+");
sprintf(action, "于%s成功存款%d元。", nowtime,money);
fseek(log, 0, 2);
fwrite(&action, sizeof(action), 1, log);
fprintf(log, "\r\n");
fclose(log);
break;
}
case 'W':
{
sprintf(Finame, "%s_%s%s", "D:\\SATM\\log", t.account, ".txt");
log = fopen(Finame, "ab+");
sprintf(action, "于%s成功取款%d元。", nowtime, money);
fseek(log, 0, 2);
fwrite(&action, sizeof(action), 1, log);
fprintf(log, "\r\n");
fclose(log);
break;
}
case 'T':
{
sprintf(Finame, "%s_%s%s", "D:\\SATM\\log", t.account, ".txt");
log = fopen(Finame, "ab+");
sprintf(action, "于%s成功向%s转账%d元。", nowtime,account,money);
fseek(log, 0, 2);
fwrite(&action, sizeof(action), 1, log);
fprintf(log, "\r\n");
fclose(log);
sprintf(Finame, "%s_%s%s", "D:\\SATM\\log", account, ".txt");
log = fopen(Finame, "ab+");
sprintf(action, "于%s成功收到来自%s转账%d元。", nowtime, t.account, money);
fseek(log, 0, 2);
fwrite(&action, sizeof(action), 1, log);
fprintf(log, "\r\n");
fclose(log);
break;
}
case 'R':
{
sprintf(Finame, "%s_%s%s", "D:\\SATM\\log", t.account, ".txt");
log = fopen(Finame, "ab+");
sprintf(action, "于%s成功修改了密码。", nowtime);
fseek(log, 0, 2);
fwrite(&action, sizeof(action), 1, log);
fprintf(log, "\r\n");
fclose(log);
break;
}
case 'L':
{
sprintf(Finame, "%s_%s%s", "D:\\SATM\\log", t.account, ".txt");
log = fopen(Finame, "ab+");
sprintf(action, "于%s注销登陆。", nowtime);
fseek(log, 0, 2);
fwrite(&action, sizeof(action), 1, log);
fprintf(log, "\r\n");
fclose(log);
break;
}
case 'Q':
{
sprintf(Finame, "%s_%s%s", "D:\\SATM\\log", t.account, ".txt");
log = fopen(Finame, "ab+");
sprintf(action, "于%s成功退出系统。", nowtime);
fseek(log, 0, 2);
fwrite(&action, sizeof(action), 1, log);
fprintf(log, "\r\n");
fclose(log);
break;
}
default:
break;
}
return 0;
}
void ZZPrint(char *a, int t)
{
char *p = a;
while (!kbhit())
{
if (*p != 0)
printf("%c", *p++);
else
break;
Sleep(t);
}
printf("%s", p);
}
int Quit(int n)
{
system("cls");
system("d:\\SATM\\logo.bat");
ZZPrint("欢迎下次使用!",100);
PrintLog('Q', 0, t.account);
Sleep(n);
exit(0);
}