The program allows a yoga studio to find loyal customers who have attended a certain number of lessons from a dataset. It reads customer information from a file and searches for customers who meet the specified lesson count.
Table of Contents 📖
Write a C program to search a list of customers based on the number of lessons they have attended. The program should read customer data from a file, search for customers who have attended more than a specified number of lessons, and then write the results to an output file.
- A file
customers.csv
containing customer data in the format:email_address, number_of_lessons, name
(one customer per line).
- The user will input the minimum number of lessons to search for.
- The program will generate an output file
result.csv
containing customers who have attended more than the specified number of lessons. The output format should match the input format.
Output file name: result.csv
Explanation:
- The program reads customer data from
customers.csv
, searches for those who have attended more than 15 lessons, and writes the result toresult.csv
.
- The program must include the function:
int search(struct customer list[], int n, int num_lessons, struct customer result[]);
- The function should search the customer list and store customers with more than
num_lessons
in the result array. - The program should handle reading and writing files as described in the input and output sections.
- The input file format should be as specified with each customer on a new line, including the email address, number of lessons, and name.
- The program should handle at most 200 customers.
1. Compile the Program:
2. Run the Program:
3. Input Required:
- Number of lessons to search for.
- Output file name.