程序博客网 > 如何增加房间湿度 知乎
来源:互联网 发布:如何增加房间湿度 知乎 编辑:程序博客网 时间:2024/04/29 18:02
#include <shlobj.h> //MessageBox #include"zh.h"
FILE *fp1;//------------------------------------------------------------------//---------------身份证号输入及验证模块---------------------------//------------------------------------------------------------------bool uidinput(ZH &p){ ZH p2; p.idInput(); fp1=fopen("d://zh.txt","a+"); //打开文件并验证账号是否存在 if(fp1==NULL){ cout<<"文件打开失败!"; system("pause"); exit(1); } if(fp1!=NULL){ while(!feof(fp1)){ fread(&p2,sizeof(ZH),1,fp1); if(strcmp(p.id,p2.id)==0){ fclose(fp1); cout<<"抱歉!该用户已开过户了!请重新输入!"; MessageBox(0,"抱歉!该用户已开过户了!请重新输入!","提示",0); return true; } } fclose(fp1); //while循环完毕,该用户尚未开通 return false; }
fclose(fp1); return false; //如果zh.txt文件空即该用户尚未开通,直接返回 }
//---------------------------------------------------------------- //-------------------------输入并验证密码-------------------------//----------------------------------------------------------------bool pwdinput(ZH &p){ system("cls"); //清屏 system("color 2"); //设置字体颜色 //cout<<"---------开户界面 ---------/n"; p.pwdInput();
printf("请再次输入密码:"); char pwd2[7]; int i=0; while(i<6){ pwd2[i]=getch(); if(pwd2[i]!='/b'){ printf("*"); i++; } else{ system("cls"); printf("请再次输入密码:"); i--; for(int j=0;j<i && i>0;j++) cout<<"*"; } } pwd2[6]='/0';
if(strcmp(p.pwd,pwd2)){ cout<<" 两次输入密码不一致!请重新输入!"; MessageBox(0," 两次输入密码不一致!请重新输入!","温馨提示",0); return true; } return false;}
//-------------------------------------------------------------//--------------------------开户模块--------------------------//-------------------------------------------------------------void kh(){ ZH p; //定义两个ZH类
bool x=false; //输入身份证号码并验证 do x=uidinput(p); while(x) ; system("color 5D"); //输入用户名 system("cls"); cout<<"---------开户界面 ---------/n"; cout<<"输入姓名:"; p.nameInput();
x=false; //输入密码并验证 do x=pwdinput(p); while(x);
x=false; //输入金额并验证 do x=p.moneyInput(); while(x);
fp1=fopen("d://zh.txt","a"); //打开并存入用户信息 if(fp1==NULL){ cout<<"文件打开失败!"; system("pause"); exit(1); } fwrite(&p,sizeof(ZH),1,fp1); fclose(fp1);
system("cls"); cout<<"---------开户界面 ---------/n"; system("color 5F"); printf("开户成功!用户信息如下:"); p.printAccount(); system("pause");}