The program reads customer data from a CSV file, sorts the customers by the number of lessons using the quick sort algorithm, and writes the sorted data to a new CSV file.
Table of Contents 📖
Modify the program from Project 7 to use quick sort to sort the customers by the number of lessons. Use the quick sort library function and implement a custom comparison function.
- The input file is named
customers.csv
and contains customer information formatted as email address (string), number of lessons (int), and name (string), with each customer on a separate line. - The program reads the file using
fscanf
with the format specifier%[^,],%d,%[^\n]\n
.
- The program outputs the sorted data to a file named
results.csv
. - The format of the output file must be the same as the input: email, number of lessons, and name, with each customer on a separate line.
email2@example.com,10,Jane Smith
email3@example.com,3,Bob Johnson
email1@example.com,5,John Doe
email2@example.com,10,Jane Smith
Explanation:
- The program reads the customer data from
customers.csv
, sorts the customers by the number of lessons in ascending order, and writes the sorted data toresults.csv
.
- The program must use quick sort to sort the customers by the number of lessons.
- Implement a custom comparison function for
qsort
. - The program should read data from an input file named
customers.csv
. - Use
fscanf
with the format specifier%[^,],%d,%[^\n]\n
to read the data into customer structures. - The program must sort the customers by the number of lessons using quick sort.
- The program must output the sorted data to a file named
results.csv
in the same format as the input. - Assume that the file will contain no more than 200 customers and that name and email are no longer than 100 characters.
1. Compile the Program:
2. Run the Program:
3. Input File:
- The input file
customers.csv
should be in the same directory as the program.
4. Output File:
- The program will create an output file named
results.csv
with the sorted customer data.