Question: Write a program that reads a file containing chemical element data and stores it in a searchable format that can display the information on demand.
Write a program that reads a file containing chemical element data and stores it in a searchable format that can display the information on demand.

Requirements The specific requirements for the 1. Define a structure layout for holding a single element's data. program are o Look at the data file to determine how many member variables your structure needs. o Choose an appropriate data type for each member variable. o For string members, allocate a reasonable size for the char array. 2. Open the input file. o You may hardcode the file name element data.txt. o If the file cannot be opened for reading, then display an error message and quit. 3. Read the file's header section (labels and number of elements). You may choose either to use or to ignore the column labels. o 4. Dynamically allocate an array of structures to hold the actual element information. o Use calloc to do this. Remember to check for NULL and free the array later. 5. Read the remainder of the file to store each element's information in the array of structures Each line's values are separated by comma characters. The scanf function will work o if you utilize the %(*.] format specifier (see Week 5 "Strings 2" lecture notes). Alternatively, you could also use the fgets and strtok functions. 6. Display a menu that prompts the user to choose one of these possible actions: o ] Display entire element array - This should display all of the element information contained in the array of structures (shown in order of increasing atomic number). o 21 Search for specific atomic number- If chosen, the program should ask the user for an atomic number and then display just that element's information. o 3 Search for specific element name If chosen, the program should ask the user for an element name and then display just that element's information. To keep things simple, the spelling has to match exactly o O Quit This allows the user to exit the program. For invalid menu numbers, display an error message and ask again. o 7. You need to write a function that displays the element information contained within a single structure. The address of the structure should be passed to the function (i.e., the parameter variable is a pointer). Use this function as needed for your various display requirements. Notes Place the data file in the same directory as your C source file. You may write additional functions if you believe they make your program more efficent. Save your program using this filename: hw6.c
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
