
- Forum
- Programming Talk
- C and C++
- What is the use of this Function
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 ...
-
03-26-2007, 03:39 PM #1
- Join Date
- Apr 2006
- Answers
- 124
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.
-
also called quick-sort, yes it is one of the sorting (a rather expensive one) method
-
03-01-2012, 06:59 AM #3
- 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.
-
04-16-2012, 04:23 PM #4
- 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

Reply With Quote





