Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in C to read the Listings.csv file. Declare a function, sortByHostName, that should sort the data based on hostname. Declare a function,

Write a program in C to read the Listings.csv file. Declare a function, sortByHostName, that should sort the data based on hostname. Declare a function, sortByPrice, that should sort the data based on price. After sorting, sortByPrice and sortByHostName should write the sorted array to a file. General Approach Declare a struct called 'Listing' with contains all the attributes found in 'Listings.csv'. Define a function that will take one line of the CSV file and return a 'Listing' struct with corresponding attribute values. Declare an array of the 'Listing' structs. Open the 'Listings.csv' file with the fopen() function in read-mode. Loop through each line of the 'Listings.csv' file. Feel free to use either the fgets() function or the getline() function. For each line, call the function you previously defined. Store the result in array of 'Listing' structs. In sortByHostName and sortByPrice, use the qsort() function to sort the array. Use the fopen() to open a file in write mode. Use the fputs() function or the fprintf() to write the sorted array to a file.

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

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

0619064625, 978-0619064624

More Books

Students also viewed these Databases questions

Question

=+j What rules will apply to the process of negotiations?

Answered: 1 week ago