Thread: Using qsort to sort an array of strings

  1. #31
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    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.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 26
    Last Post: 07-05-2010, 10:43 AM
  2. Replies: 2
    Last Post: 07-11-2008, 07: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, 02: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, 12:04 PM