Example 91: Cricket Scores
Explore how to create and manipulate an array of structures in C to store cricket player data. Learn to implement sorting by average runs using the standard qsort function along with a custom comparison function to handle structure pointers.
We'll cover the following...
We'll cover the following...
Problem
A record contains the name of a cricketer, the age, the number of test matches he has played, and the average runs he scored in each test match. Create an array of structures to hold records of 5 such cricketers, and then write a program to read these records and arrange them in ascending order by average runs. Use the qsort() standard library function.
Try it yourself
Try to solve this question on your ...