Question: Write two functions, which read/write an array of accounts to/from a file. Write driver code to test the two functions. The driver code and the
Write two functions, which read/write an array of accounts to/from a file. Write driver code to test the two functions. The driver code and the test output must show clearly that the file input and output work correctly.
Requirements:
Definition of Account
Create a header file, account.h, containing the following definition. Note that the structure is different from that in the previous assignments.
struct account { char name[25]; int accountno; float balance; }; // This semicolon is important!!!
Read/Write Functions
Create a source file, iofunctions.c, containing the following functions.
int readfile( struct account accarray[ ], int * numcust, char filename[ ] ); int writefile( struct account accarray[ ], int numcust, char filename[ ] );
Basic specifications
The function, readfile, will read the data from a text file and store it in the array specified by accarray. It must tell the function which called it how many accounts it has stored into the array.
The function, writefile, will write the data stored in the array specified by accarray into a text file.
The return values will be used to tell whether the functions successfully read/write data.
The size of the array and the name of the text file are assumed to be arbitrary (You cannot specify them in this file).
The functions must not have user I/O (printf, scanf, etc).
Driver Code
Define the following local variables in the main function:
struct account bankone[5]; int numcustomers;
A menu is not required. The user-interface can be very simple, but the output of the program must be clear and self-explanatory and must be definitive proof that the functions work.
You may get input from the keyboard or hardcode your array in the driver for testing.
The driver code must be written in different c file(s) rather than iofunctions.c.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
