Question: C PROGRAMMING C PROGRAMMING Problem P.5 Using qsort() (7 points) Consider the following data structure: struct river { char name [40]; int length; int drainage_area;
C PROGRAMMING
C PROGRAMMING

Problem P.5 Using qsort() (7 points) Consider the following data structure: struct river { char name [40]; int length; int drainage_area; }; Write a program that reads data from a file named data.txt and then sorts the rivers by length using the predefined qsort () function. The result is written to a file. The name of the file is being read from the keyboard. You will also need to implement a comparison function to make qsort () work correctly. If you do not know how to do this, just skip it, but still call the qsort () function. You can assume that the struct above are part of your program, and that data.txt will never contain more than 30 entries. You may not use global variables. An example for the content of data.txt can be the following: Nile 6650 334900 Amazon 6400 6915000 Yangtze 6300 1800000 Mississippi-Missouri 6275 2980000 Yenisei-Angara-Selenga 5539 2580000 Yellow 5464 745000 Ob-Irtysh 5410 2990000 Congo-Chambeshi 4700 3680000
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
