Code Snippets C

#include
#include
int comp(const void *x, const void *j);
int main(void)
{
int sort[100], x;
/* set the array with random numer*/
for(x = 0; x < 100; x++)
sort[x] = rand();
/* call the quick sort */
qsort(sort, 100, sizeof(int), comp);
for(x = 0; x < 100; x++)
printf("%d\n", sort[ x ]);
return 0;
}
int comp(const void *x, const void *j)
{
return *(int*)x - *(int*)j;
}