Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int sort(const void* a, const void* b)
- {
- const char *ia = *(const char**)a;
- const char *ib = *(const char**)b;
- return strcmp(ia + 2,ib + 2);
- }
- int main()
- {
- char *ArrayFinal[4] =
- {
- {"2 -4 THIS IS LINE ONE"},
- {"1 -3 THIS IS LINE TWO"},
- {"6 -8 THIS IS LINE THREE"},
- {"3 -2 THIS IS LINE FOUR"}
- };
- qsort(ArrayFinal, (size_t)4, sizeof(char *), sort);
- int i;
- for(i = 0; i < 4; i++)
- printf("%s \n", ArrayFinal[i]);
- printf("Hello!");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment