0

I got a structure:

typedef struct people
{
  char name[50];
  int money;
} PEOPLE;

And I have a text file, where are names of the people with their money:

A 3 650
B 7 000
C 5 000
D 857
E 12 000
F 4 780
G 890
.
.
.

In the rest of the code I open the text file with names and money and with the while loop I read the everything in the file till the end. Now I want to sort them from "best" to "worse" by the amount of their money, so the "best" will be in this case C with 5 000, then a person with lower money, then anoher with lower....

I found a function qsort() which I want to use in my program, but I´m not sure how to use it.

Stargateur
  • 24,473
  • 8
  • 65
  • 91
Masielko
  • 13
  • 6
  • What is prototype of that function? Build the arguments as per the prototype and pass to that function. What have you tried? – Vagish Nov 25 '17 at 15:12
  • Please see my answer [here](https://stackoverflow.com/questions/47358051/sorting-string-containing-numbers-entered-from-a-file-in-c/47361237#47361237). It might help you structure your solution. – vitruvius Nov 25 '17 at 15:28

0 Answers0