Question: How would i write a code for this in c language. All projects require that up to 5 sets of input values can be stored
How would i write a code for this in c language.
All projects require that up to 5 sets of input values can be stored in a file and reselected by the user when starting the program again.
Here are a few hints:
o Ensure that your software is designed to check the user input values (Section 2 of the project should provide information on valid values for user input).
o Use a structure whose members contains all user input values.
o Define an array of 5 structure values.
o The array can then be written with a single fwrite function call to a binary file and read from the binary file using a single fread function call.
o Add a member to the structure to indicate if the structure element in the array has been filled (i.e. is TRUE when filled, and FALSE when free to accept values).
o Define a file name (e.g. file.bin, do choose a more significant name than file) as a symbolic constant: #define BINFILE file.bin. You can then use BINFILE with fopen as in: fp = fopen(BINFILE, wb);
o When starting the program check if the file exists (try to open the file for reading).
If it does not exist, then create a new file and save the structure array (with all elements in the array initialized to available) into the file. Then ask the user for new input values.
If the file exists, list the contents of each element in the array (with some message like: Available for elements that do not yet have values). Prompt the user to see if one of the existing values is to be used or to select new values
o When a new set of values is given by the user, prompt the user to save the values. If an element in the array is available, update it with the new values; otherwise prompt the user to replace an existing set of values.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
