C Tutorial/stdlib.h/qsort

Материал из C\C++ эксперт
Версия от 13:32, 25 мая 2010; Admin (обсуждение | вклад) (1 версия: Импорт контента...)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

qsort

Item Value Header file stdlib.h Declaration void qsort(void *buf, size_t num, size_t size, int (*compare) (const void *, const void *)); Function sorts the array *buf using a Quicksort. Parameter The number of elements in the array is specified by num, and the size (in bytes) of each element is described by size.

The function pointed to by compare is used to compare two elements of the array.

The form of the compare function must be as follows:


<source lang="cpp">int func_name(const void *arg1, const void *arg2);</source>