C语言qsort库函数使用说明: https://blog.csdn.net/linaijunix/article/details/50358518
#include<stdio.h>
#include<stdlib.h>
int cmp(char *s1, char *s2);
int main(){
int i;
char s[5][85];
for(i = 0; i < 5; i++)
scanf("%s", s[i]); //读入5个字符串
qsort(s, 5, sizeof(s) / 5, cmp); //sizeof(s) / 5 为每个一维数组的大小
printf("After sorted:\n");
for(i = 0; i < 5; i++)
printf("%s\n", s[i]);
return 0;
}
int cmp(char *s1, char *s2){ //自写比较函数
return strcmp(s1, s2);
}