[prev] 14 [next]

Exercise 4: Sorting on Different Fields

Write a program that reads data in the form:

5059413 Daisy  3762  15
3461045 Yan    3648  42
3474881 Sinan  8543  16
5061020 Yu     3970  3

and then ..

  • stores it in an array of Student structs {sid,name,prog,magic}
  • uses qsort() to sort it; sort order determined by argv[1]
  • writes out sorted array, one Student per line