its working account number 101-530 but it not working account number
535-565
acct.dat
101   Checking account #1     1032.57  2114.56  5219.23
102   Checking account #2      543.78  3094.17  1321.20
505   Advertising expense       25.00    25.00    25.00
510   Auto expenses            195.40   307.92   501.12
515   Bank charges               0.00     5.00     5.00
520   Books and Publications    27.95    27.95    87.40
525   Interest Expense         103.50   255.20   380.27
530   Legal expense
535   Miscellaneous expense     12.45    17.87    23.87
540   Office expense            57.50   105.25   138.37
545   Postage and shipping      21.00    27.63    57.45
550   Rent                     500.00  1000.00  1500.00
555   Supplies                 112.00   167.50   241.80
560   Travel and entertainment  62.76   198.12   307.74
565   Utilities                 84.89   190.60   278.48



# include <stdio.h>
# include <ctype.h>
# define MAX 15

struct account{

int acctnum;
char accttitle[32];
float jan;
float mar;
float feb;
};

main ()
{
struct account bank[MAX];
FILE *rp;
int i=0;

rp=fopen("acct.dat", "r");

printf("%s%15s%13s%13s%13s\n","Acct No.","Account
title","Jan","Feb","Mar");

for (i=0; i<MAX; i++){
fgets(bank[i].accttitle,32,rp);
fscanf(rp,"%f %f %f\n",&bank[i].jan,&bank[i].feb,&bank[i].mar);
fscanf(rp,"\n");
fflush(stdin);
}
for (i=0; i<MAX; i++)
{
printf("%s %-13.2f %-13.2f %-13.2f\n ",bank[i].accttitle,bank
[i].jan,bank[i].feb,bank[i].mar);
fprintf(rp,"%d",bank[i].acctnum);
fscanf(rp,"\n");
fflush(stdin);
}
}

Reply via email to