SW006013 Microchip Technology, SW006013 Datasheet - Page 110

MPLAB C Compiler For DsPIC DSCs

SW006013

Manufacturer Part Number
SW006013
Description
MPLAB C Compiler For DsPIC DSCs
Manufacturer
Microchip Technology
Series
DsPIC30F/33Fr
Type
MPLAB® C Compilerr
Datasheet

Specifications of SW006013

Supported Families
DsPIC30F, DsPIC33F
Core Architecture
DsPIC
Kit Contents
Software And Docs
Mcu Supported Families
DsPIC30F And DsPIC33F
Tool Function
Compiler
Tool Type
Compiler
Processor Series
dsPIC
Lead Free Status / RoHS Status
na
For Use With/related Products
dSPIC DSCs
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
DS51456E-page 106
qsort
Description:
Include:
Prototype:
Arguments:
Remarks:
Example:
Performs a quick sort.
<stdlib.h>
void qsort(void *base, size_t nelem, size_t size,
base
nelem
size
cmp
e1
e2
qsort overwrites the array with the sorted array. The comparison func-
tion is supplied by the user. In the following example, the list is sorted
according to the comparison function. This comp uses ascending order.
#include <stdlib.h> /* for qsort
#include <stdio.h>
#define NUM 7
int comp(const void *e1, const void *e2);
int main(void)
{
}
int comp(const void *e1, const void *e2)
{
}
Output:
Unsorted List: 35
Sorted List:
int (*cmp)(const void *e1, const void *e2));
int list[NUM] = {35, 47, 63, 25, 93, 16, 52};
int x;
printf("Unsorted List: ");
for (x = 0; x < NUM; x++)
qsort(list, NUM, sizeof(int), comp);
printf("\n");
printf("Sorted List:
for (x = 0; x < NUM; x++)
const int * a1 = e1;
const int * a2 = e2;
if (*a1 < *a2)
else if (*a1 == *a2)
else
printf("%d
printf("%d
return -1;
return 0;
return 1;
pointer to the start of the array
number of elements
size of the elements
pointer to the comparison function
pointer to the key for the search
pointer to the element being compared with the key
16
", list[x]);
", list[x]);
47
25
/* for printf */
63
35
");
25
47
© 2008 Microchip Technology Inc.
93
52
*/
16
63
52
93

Related parts for SW006013