totn C Functions

C Language: qsort function
(Sort Array)

In the C Programming Language, the qsort function sorts the array pointed to by base.

Syntax

The syntax for the qsort function in the C Language is:

void qsort(void *base, size_t num_members, size_t size, 
           int (*compare_function) (const void *, const void *));

Parameters or Arguments

base
The array to sort.
num_members
The number of elements in the array.
size
The size of the elements in bytes.
compare_function
A pointer to a comparison function.

Returns

The qsort function returns a negative, zero, or positive integer (based on whether the first element in the array is less than, equal to, or greater than the second element in the array).

Required Header

In the C Language, the required header for the qsort function is:

#include <stdlib.h>

Applies To

In the C Language, the qsort function can be used in the following versions:

  • ANSI/ISO 9899-1990

Similar Functions

Other C functions that are similar to the qsort function: