Using qsort to sort an array of strings

This is a discussion on Using qsort to sort an array of strings within the C Programming forums, part of the General Programming Boards category; c.user, even if what you proposed were absolutely legal, what advantage would it provide? You would require that users of ...

  1. #31
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,303
    c.user, even if what you proposed were absolutely legal, what advantage would it provide? You would require that users of your comparator cast the function pointer for each use, whereas with the canonical version they would just need to provide the function pointer to the comparator.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  2. #32
    Registered User
    Join Date
    Apr 2009
    Location
    Russia
    Posts
    116
    Oh, I can sort this functions
    qsort and strcmp are irrelevant

    I can have more compare functions, when you have more than ten or twenty functions it is easier to look only for their headers (to know what is they do), and if you have a compare function which longer than one line or five lines it will save your time

    example with the function which irrelevant to qsort
    Attached Files Attached Files

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 11:43 AM
  2. Replies: 2
    Last Post: 07-11-2008, 08:39 AM
  3. How to sort an array of pointers to structure
    By broli86 in forum C Programming
    Replies: 3
    Last Post: 06-30-2008, 03:52 PM
  4. Sorting strings in an array
    By JLan in forum C Programming
    Replies: 4
    Last Post: 11-29-2003, 05:10 PM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 01:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21