コード例 #1
0
ファイル: Bank.cpp プロジェクト: Rahul147/BankManagement_CPP
void modify_account(int n)
{
	int found=0;
	fstream File;
	File.open("account.dat",ios::binary|ios::in|ios::out);
	if(!File)
	{
		cout<<"File could not be open !! Press any Key...";
		return;
	}
	while(!File.eof() && found==0)
	{
		File.read((char*)&ac, sizeof(ac));
		if(ac.retacno()==n)
		{
			ac.show_account();
			cout<<"\n\nEnter The New Details of account"<<endl;
			ac.modify();
		     	int pos=(-1)*static_cast<int>(sizeof(account));
			File.seekp(pos,ios::cur);
			File.write((char*) &ac, sizeof(ac));
			cout<<"\n\n\t Record Updated";
			found=1;
		  }
	}
	File.close();
	if(found==0)
		cout<<"\n\n Record Not Found ";
}
コード例 #2
0
ファイル: Bank.cpp プロジェクト: Rahul147/BankManagement_CPP
void deposit_withdraw(int n, int option)
{
	int amt;
	int found=0;
	fstream File;
	File.open("account.dat", ios::binary|ios::in|ios::out);
	if(!File)
	{
		cout<<"File could not be open !! Press any Key...";
		return;
	}
	while(!File.eof() && found==0)
	{
		File.read((char*)&ac, sizeof(ac));
		if(ac.retacno()==n)
		{
			ac.show_account();
			if(option==1)
			{
				cout<<"\n\n\tTO DEPOSITE AMOUNT ";
				cout<<"\n\nEnter The amount to be deposited";
				cin>>amt;
				ac.dep(amt);
			}
			if(option==2)
			{
				cout<<"\n\n\tTO WITHDRAW AMOUNT ";
				cout<<"\n\nEnter The amount to be withdraw";
				cin>>amt;
				int bal=ac.retdeposit()-amt;
				if((bal<500 && ac.rettype()=='S') || (bal<1000 && ac.rettype()=='C'))
					cout<<"Insufficience balance";
				else
					ac.draw(amt);
			}
コード例 #3
0
ファイル: Bank.cpp プロジェクト: Rahul147/BankManagement_CPP
void display_sp(int n)
{

	int flag=0;
	ifstream fin;
	fin.open("account.dat",ios::binary);
	if(!fin)
	{
		cout<<"File could not be open !! Press any Key...";
		return;
	}
	cout<<"\nBALANCE DETAILS\n";
	fin.read((char*)&ac, sizeof(ac));
	while(fin)

	{
		if(ac.retacno()==n)
		{
			ac.show_account();
			flag=1;
		}
	}
	fin.close();
	if(flag==0)
		cout<<"\n\nAccount number does not exist";
}