I don't believe you need an array for the transactions, just for the accouints. Each account will have 3 parts:
1) The account number (used for searching and must be unique)
2) The account owner
3) The current balance
I would advise making the above, into a text file. Then when the program starts, it can build it's array from that file, without you having to enter the data for all accounts, each time you want to run the program.
Saves a lot of time and keyboarding!
The above screams for a struct. The struct definition goes before main():
(This is an idea, not runnable code)
Code:
struct accouint {
unsigned long number;
char lname[25];
char fname[25];
unsigned long dollar;
int cents;
}
struct account acc[50] //make an array of 50 accouts
Now you have a second text file, with transactions in it:
Account number Debit or Credit Amount
1001 D 56.23
1185 C 300.00
etc.
Code:
while((fscanf(fp,"%U %s %s %U %c %d", acc.number, acc.lname acc.fname, acc.dollar, dot, acc.cents) == 6) {
//dot is just for the decimal place
}
Your program first loads the accounts data, into the array of structs, and then opens the transaction data file, and begins processing in a loop similar to the above while loop.
The accounts will all be sorted according to the account number, and you'll want a binary search to find them (hardly necessary with these numbers, but great when your banking business has 10,000 customers.
Dividing up the dollars and the cents makes good sense, because it stops any floating point error, before it can even start.
Debit and Credit refer to bookkeeping. Debits are deposits, credits are withdrawals.
When all the transactions are processed, you need to write out the new data from the array to the ledger file, again using a do while or while loop.
For a more robust program, I'd say put the array declaration in main(), and dynamically malloc the memory, but that would just complicate matters unnecessarily for a beginner.
This is something you can always add later on.
Oooo-rah! I smell version 2!