Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For this assignment, you need only write a single-file C program. Your program will: Define a C structure sample: Suitable to hold the defining characteristics
For this assignment, you need only write a single-file C program. Your program will: Define a C structure sample: Suitable to hold the defining characteristics of a sample char* name, float value} - call this format a Sample data record Write a separate function to: Read a file of delimited Sample data records into an array of pointers to your sample structs. Note you may use a statically sized array of size 1024, however, each element of the array must be a pointer to a sample struct (as defined above). Initially each element of the array must be set to NULL (to indicated that it is not used), and then later to a dynamically allocated sample struct if it is to be us Note: after dynamically allocating memory for a sample struct, you have enough memory for each/every component of the structure. However, for each component of that structure that is a pointer, you will eventually need to allocated memory for the thing that it points to as well (think string via char * ). You will also have to remember this when freeing memory via a pointer toa sample struct. Write a separate function to: Create a new (buffered binary) file and write all the used elements of the array ( of sample structs ) to this file. Write a separate function to: Free all of the used elements of the array ( of sample structs ) that means all the memory that was allocated for each element ( the structure and its components ) Write a separate function to: Read a file of your sample structs, ( as it was created by your second function ) and display each in a reasonable report like format to the screen Note: you will need to create a text file of of delimited Sample data records in an editor, and store it in the same project as your C -program file in order to test / run your program file.txt Where jdi is a delimiter character that would not occur naturally in a name like
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