Question
Using C programming language your task is to code in a C programming language to read in student names and grades from separate files, and
Using C programming language
your task is to code in a C programming language to read in student names and grades from separate files, and print out the students names and grades. A Screen shot will be provided below this task which will have the student names, their grades, ID number and all the data you will need. You can create your own CSV file using the information in the screenshot
Details
Your program should read in a student CSV file and an activity CSV file and output the student first name, last name and grade in the format specified below.
You are free to choose whichever method you want to implement your program with the following restrictions:
- your implementation must contain a correctly declaredmain function
- you are not allowed to use global variables
- all dynamically allocated memory should be freed
- all user file handles should be closed
You can use any standard library functions (including those in the C maths library).
Your program should take two command line arguments: the filename of the student CSV file and filename of the activity CSV file respectively. It should output the student first name, last name and grade. For example:
$ ./task2 class01_students.csv class01_activity01.csv
Sherri Hurrington 30
William Rich 0
Erin Simmons 16
Antonio Levi 75
Mabel Henderson 41
Paula Coffey 62
Tom Green 56
Hazel Willis 70
Marty Osterberg 0
Nancy Winders 90
$ ./task2 class01_students.csv class01_activity02.csv
Sherri Hurrington 44
William Rich 0
Erin Simmons 75
Antonio Levi 97
Mabel Henderson 29
Paula Coffey 89
Tom Green 62
Hazel Willis 90
Marty Osterberg 13
Nancy Winders 34
All students should be output in the same order as they appear in the student CSV file. If a student was absent for an activity, they should be awarded a grade of 0.
Your program will be tested against a number of randomly generated classes. Your program will also be tested against a number of invalid cases e.g. an incorrect number of command line arguments, or incorrect numbers of columns in the student or activity CSV files. In these cases, an error message should be printed and your program should immediately exit with a non-zero exit code. All error messages in your implementation should be printed tostderr.
.
- free the memory for the activity and student arrays.
Your program should handle dynamically allocated memory correctly i.e. free all dynamically allocated memory. It should also make sure all user file handles are closed before it exits.
Class01_activity01.csv data below Class01_activity02.csv
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