This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/qsort.c

21 lines
478 B
C
Raw Normal View History

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *CharVect[] = { "last", "middle", "first" };
int compare( const void *op1, const void *op2 )
{
const char **p1 = (const char **) op1;
const char **p2 = (const char **) op2;
return( strcmp( *p1, *p2 ) );
}
void main()
{
qsort( CharVect, sizeof(CharVect)/sizeof(char *),
sizeof(char *), compare );
printf( "%s %s %s\n",
CharVect[0], CharVect[1], CharVect[2] );
}