[求助]对五个字符串进行排序
对"jegged","king","software","today","hello"这个五个字符串进行排序。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int sort_function( const void *a, const void *b);
char list[5][20]={"jegged","king","software","today","hello"};
int main(void)
{
int x;
qsort((void *)list, 5, sizeof(list[0]), sort_function);
for (x = 0; x < 5; x++)
printf("\n%s", list[x]);
getch();
return 0;
}
int sort_function( const void *a, const void *b)
{
return( strcmp(a,b) );
}