Exforsys
+ Reply to Thread
Results 1 to 4 of 4

What is the use of this Function

This is a discussion on What is the use of this Function within the C and C++ forums, part of the Programming Talk category; I want to know the use of qsort function in C programming language. Is this used for sorting elements as ...

  1. #1
    Rahulbatra is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    124

    Question What is the use of this Function

    I want to know the use of qsort function in C programming language. Is this used for sorting elements as the name implies.


  2. #2
    zsk_00 is offline Member Array
    Join Date
    May 2006
    Answers
    37
    also called quick-sort, yes it is one of the sorting (a rather expensive one) method


  3. #3
    Sandhya.Kishannag is offline Member Array
    Join Date
    Feb 2012
    Answers
    66
    qsort() is standard C function for sorting arrays. It is defined by ISO C standard, and implemented in most C/C++ standard libraries(stdlib.h)

    qsort() takes four arguments:

    void qsort(void *base, size_t nel, size_t width, int (*compar)(const void *, const void *));

    * base — is a pointer to the beginning of data array
    * nel — is a number of elements
    * width — is a size of each element (in bytes)
    * compar — is a callback function (pointer to function), which does comparison and returns positive or negative integer depending on result.


  4. #4
    webcurious is offline Junior Member Array
    Join Date
    Apr 2012
    Answers
    12
    This explanation of qsort definitely helps. The explanation of base, nel, width, compar, is also very handy. It's amazing what just a little teaching can do for a beginning programming student.


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...