Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Topics: Files + File Streams in C. For this assignment, you need only write a single-file C program. Your program will: Define a C structure

Topics: Files + File Streams in C.

For this assignment, you need only write a single-file C program. Your program will:

Define a C structure ( contact struct ) suitable to hold the defining characteristics of a:

Sample (char* name, int list_len, float* value_list) - call this format a Sample data record.

Write a separate function to :

Read a file (created in a text editor pico) 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 used.

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* , array via float*). You will also have to remember this when freeing memory via a pointer to a sample struct.

Write a separate function to :

Create a new file and write all the used elements of the array ( of sample struct s ) to this file. You must use binary writes for all of C's built-in numeric types.

Write a separate function to :

Free all of the used elements of the array ( of sample struct s ) 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 struct s, ( as it was created by your second function ) and display each in a reasonable report like format to the screen.

image text in transcribed

CS337 System Programming Programming Assignment #6 Due Wednesday, November 1st, 11:59pm Topics: Files File Streams in C For this assignment, you need only write a single-file C prpgram. Your program will: Define a C structure (contact struct) suitable to hold the defining characteristics of a: Sample (char* name, int list len, float value _list) - call this format a Sample data record. Write a separate function to Read a file (created in a text editor -pico) 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 used. 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* , array via float). You will also have to remember this when freeing memory via a pointer to a sample struct. . Write a separate function to Create a new file and write all the "used" elements of the array (of sample struct s) to this file. You must use binary writes for all of C's built-in numeric types. Write a separate function to Free all of the "used" elements of the array ( of sample struct s) -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 struct s, ( as it was created by your second function) and display

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Larry Ellison Database Genius Of Oracle

Authors: Craig Peters

1st Edition

0766019748, 978-0766019744

More Books

Students also viewed these Databases questions