i am new to programming and am struggling with a homework project. Please help
Here are the requirements
need a program to store account information of a bank
need to store
id, one-word name, current balance.
i need to read transactions from a file. typical transactions look like this
1234 jon 123.45
4001 jake 1005.50
i have a few rules to go by..
can only have a max of 16 accounts
id's are int between 1000 and 9999
names are one word with less than 10 letters
names on transactions must match names in account
reject transactions that produce negative balances
i need to use arrays for id, name, amounts and store them in ascending order based on id.
i need to provide a reason for any account transaction being rejected... i.e invalid id, name, etc..
after reading all transactions from file need to write the id, name and final balance to file called account.txt..
heres what i have so far... i need some direction what to do next.. thanks
#define LIMIT 48
#define LENGTH 16
char acct_info[LIMIT][LIMIT], buffer[4*LENGTH];
int i, size = 0;
file = fopen("transact.txt", "r");
perror("UNABLE TO OPEN transact.txt\n");
while(fscanf(file, "%s", buffer) ==1)
if(strlen(buffer) < LENGTH -1 )
if(size < LIMIT)
printf("there is no room in the array for %s\n", buffer);
printf("%s is too long\n", buffer);
file = fopen("account.txt", "w");
perror("UNABLE TO OPEN account.txt\n");
for(i = 0; i < size; ++i)
fprintf(file, "%s\n", acct_info[i]);