Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * C Program To Sort array in ascending order using Quicksort.
- */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <time.h>
- #define SIZE 50000
- static int compare(const void *a, const void *b)
- {
- /* The pointers point to offsets into "array",
- so we need to dereference them to get at the strings. */
- return strcmp(*(const char **) a, *(const char **) b);
- }
- int main(int argc, char *argv[])
- {
- str page[SIZE];
- int size = read(page);
- // create an array of random ints
- srand(time(NULL));
- for (int i = 0; i < SIZE; i++) array[i] = rand();
- qsort(page, size, sizeof(const char *), compare);
- // output array
- for (int i = 0; i < SIZE; i++) printf("%i\n", array[i]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement