⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 旧用户验证.cpp

📁 大一时候学C++的大作业,独立开发的一个模拟银行系统,还存在点缺陷,不过相信对初学者来说还有帮助的,里面有作业报告和工作日记.
💻 CPP
字号:
#include"head.h"
////////////////////////////////////用户登录验证系统///////////////////////////
void System::oldconsumerchk(char oldnamechk[40] , char oldpassword[5])
{    
    memberdata logchk;
    System log_in;
	
   fstream f("consumer.dat",ios::binary|ios::in);
   f.seekg(0,ios::end);
    long pos=f.tellg();
	if(!f)
	{cerr<<"文件不能打开"<<endl;
     return;
	}
int c;
int d;
f.seekg(0,ios::beg);

 do
 { f.read((char *)&logchk,sizeof(memberdata));
   c=strcmp(logchk.Name,oldnamechk);
 }while(f.tellg()!=pos);
    
 if(c==0)
 {
	 do
	 { 
		 f.read((char *)&logchk,sizeof(memberdata));
         d=strcmp(logchk.password,oldpassword);
	 }while(f.tellg()!=pos);
	
	 if(d==0)
	{
		 cout<<"用户信息核对成功\n"<<endl;
           system("cls");
          cout<<"欢迎光临"<<endl;
           log_in.menu();
	}
	 else if(d!=0)
	 {
		 cout<<"用户信息核对失败,请重新输入正确的用户名或密码.谢谢~!111"<<endl;
		 cout<<endl;
	 }
 }

 else if(c!=0)
 {
	 cout<<"用户信息核对失败,请重新输入正确的用户名或密码.谢谢~!222222"<<endl;
	 cout<<endl;
 }
f.close();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -