Hello everyone. I have a problem to search - [by using customer's name] - for a customer's bank account details from a binary .dat file. Here are some relevant codes that I think you guys can help me out.
deposit_withdraw (char& acc_name,char& accounts_menuact)
{
Savings s3;
fstream inout_stream;
inout_stream.open ("account details.dat", ios::binary|ios::out|ios::in);
if (!inout_stream)
{
cout << "Unable to open file ! Press Any Key . . .";
return;
}
while ((!inout_stream.eof ()) && (find_record == false))
{
inout_stream.read(reinterpret_cast<char *>(&s3), sizeof(Savings));
if (acc_name == s3.input_accname ()) //this condition doesn't work
{
system ("cls");
s3.layout ();
if (accounts_menuact == '2')
{
cout << "DEPOSIT MONEY INTO ACCOUNT";
cout << "Enter amount of money to be deposited : RM ";
cin >> amount;
s3.deposit_money (amount);
}
elseif (accounts_menuact == '3')
{
cout<<"WITHDRAW MONEY FROM ACCOUNT ";
cout<<"Enter amount of money to be withdraw : RM ";
cin>>amount;
//the coding continues...
}
Call input_accname function to validate customer's identity.
1 2 3 4
char input_accname ()
{
return acc_name[20];
}
I thought of using string to store acc_name as its variable, but after I've done some research, I found out line 13 doesn't accept string data type.So I'm open to any suggestions or help from you guys. Thanks.
I'm aware you can't pass array as a parameter in a function,thus you're seeing this post.
Would it help to know that you can still effectively pass an array into a function by just passing the name of the array, which passes the address of its first element? Check out this article, particularly "Arrays as Parameters": http://www.cplusplus.com/doc/tutorial/arrays/
You should be able to make the function header look like