Question: Write two functions, which read/write an array of records 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 records 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
1. Definition of Record
Create a header file, record.h, containing the following definition.
Note that the structure is different from the one used in the previous assignments.
struct record { int accountno; char name[25]; char address[80]; };
2. Read/Write Functions
Create a source file, iofunctions.c, containing the following functions.
int readfile( struct record accarray[ ], int* numcust, char filename[ ] ); int writefile( struct record accarray[ ], int numcust, char filename[ ] );
Basic specifications
The function, readfile, will read the data from a text file and store it in the array called by accarray.
It must tell the function which called readfile how many records 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/wrote 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 the terminal I/O's (printf, scanf, etc).
3. Driver Code
Define the following local variables in the main function:
struct record 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.
Please make sure that your test cases can really prove that the functions work. (Check if your test case could provide the same results even if they don't work.)
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
