output is differnent
admin@admin-PC MINGW64 ~/test
$
admin@admin-PC MINGW64 ~/test
$ cat aa.c
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <locale.h>
int main (void){
int i;
char str[10][4]= {"镕","堃","趙","錢","孫","李","周","吳","鄭","王"};
qsort (str, 10, 4, strcoll);
printf ("按内码排序:");
for (i=0; i<10; i++)
printf ("%s", str[i]);
setlocale (LC_ALL, "");
qsort (str, 10, 4, strcoll);
printf ("\n按音序排序:");
for (i=0; i<10; i++)
printf ("%s", str[i]);
return 0;}
admin@admin-PC MINGW64 ~/test
$ gcc aa.c -o aa.exe
aa.c: 在函数‘main’中:
aa.c:8:24: 警告:传递‘qsort’的第 4 个参数时在不兼容的指针类型间转换 [-Wincompatible-pointer-types]
qsort (str, 10, 4, strcoll);
^
In file included from /usr/include/stdio.h:29:0,
from aa.c:1:
/usr/include/stdlib.h:139:7: 附注:需要类型‘__compar_fn_t {或称 int (*)(const void *, const void *)}’,但实参的类型为‘int (*)(const char *, const char *)’
_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, __compar_fn_t _compar));
^
aa.c:13:24: 警告:传递‘qsort’的第 4 个参数时在不兼容的指针类型间转换 [-Wincompatible-pointer-types]
qsort (str, 10, 4, strcoll);
^
In file included from /usr/include/stdio.h:29:0,
from aa.c:1:
/usr/include/stdlib.h:139:7: 附注:需要类型‘__compar_fn_t {或称 int (*)(const void *, const void *)}’,但实参的类型为‘int (*)(const char *, const char *)’
_VOID _EXFUN(qsort,(_PTR __base, size_t __nmemb, size_t __size, __compar_fn_t _compar));
^
admin@admin-PC MINGW64 ~/test
$ ./aa.exe
按内码排序:吳周堃孫李王趙鄭錢镕
按音序排序:堃李錢镕孫王吳趙鄭周
admin@admin-PC MINGW64 ~/test
$
复制代码