Question
Prepare the following struct definition and function prototypes: // File: record.h struct record { int accountno; char name[25]; char address[80]; struct record* next; }; //
Prepare the following struct definition and function prototypes:
// File: record.h struct record { int accountno; char name[25]; char address[80]; struct record* next; }; // This semicolon is important!!!
// Prototypes void addRecord (struct record **, int, char [ ],char [ ]); int printRecord (struct record *, int); void printAllRecords(struct record *); int deleteRecord(struct record **, int); int readfile(struct record **, char []); void writefile(struct record *, char []);
// Define as a local variable within the main function: struct record *start = NULL;
User interface
You must use a while or do-while loop for the menu.
For each menu option, collect the appropriate information from the user.
The name field must allow spaces; it must be able to contain multiple names (the user can put/opmit his/her middle name, suffix etc.)
The address field should be capable of storing multiple-line addresses; the number of lines must be arbitrary.
Write your own getaddress function to obtain the address information since the address field may have multiple lines of address and must be stored as one character array. You cannot ask the user how many lines of address they are typing.
Prototype for the above function is void getaddress (char [ ], int);
You may create any other functions you like or add to the menu in the interface.
Database functions
addRecord will add/insert a new record into the list so that all records are sorted in ascending order by account number.
addRecord will not accept a duplicate account number. Instead, it will increament the new account number so all records have different numbers.
e.g., when you are inserting "1001" to the list of "1000, 1001, 1002, 1003, 1008, 1010", the result will be "1000, 1001, 1002, 1003, 1004, 1008, 1010" where "1004" is the newly added one.
printRecord will print the record with the matching accountno
printAll will print the contents of the entire database
deleteRecord will delete the record with the specified accountno.
readfile must be called once at the start of the main function
writefile must be called once at the end of the main function
You cannot change the definition of the record datatype
You cannot change the arguments used by the functions shown above.
You cannot create any additional database functions without my consent.
Source files
There must be a minimum of two files, one for the user-interface functions and one file for the database functions.
Makefile must be used.
Materials to submit
PROGRAM:
Source code (all files you need to compile your code, including the Makefile)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started