查看记录.cpp

来自「大一时候学C++的大作业,独立开发的一个模拟银行系统,还存在点缺陷,不过相信对初」· C++ 代码 · 共 52 行

CPP
52
字号
#include"head.h"
//////////////////////////////////////////////查看记录////////////////////////////////////////
void operate::browsefile()
{   System op;
	memberdata bf;
	int choice;
	int n;
	char name[40];
	fstream f("consumer.dat",ios::binary|ios::in|ios::out);
	f.seekg(0,ios::end);
  long posEnd=f.tellg();
  
	cout<<"请再次输入你的用户名:";
  cin>>name;
	system("cls");

  cout<<"****************************查询****************************\n";
   cout<<setw(55);
   op.timeshow();
   cout<<endl;
  
  //f.seekg(0,ios::beg);

  do{
	  f.read((char *)&bf,sizeof(memberdata));
   n=strcmp(bf.Name,name);
  }while(f.tellg()!=posEnd);
  
  if(n==0)
  {
   cout<<"Member's name: "<<bf.Name<<'\n'
	       <<"存款余额: "<<bf.cash<<'\n'
		   <<"          "<<bf.cash1<<'\n'
		   <<"          "<<bf.cash2<<'\n'
		   <<"可支取金额:"<<bf.cash-1<<'\n'
	       <<"            "<<bf.cash1-1<<'\n'
	       <<"            "<<bf.cash2-1<<endl;
       
       cout<<"1:建立文本输出记录"<<endl;
   	   cout<<"0:返回"<<endl;
	   cin>>choice;
	   switch(choice)
	   {
	    case 0:return;break;
	    case 1:op.CreateTxt();
	    default:cout<<"ERROR......"<<endl;
	   }
  }
  else cout<<"输出错误"<<endl;
  
  f.close();
}

⌨️ 快捷键说明

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