qsort()给字符串排序问题

rzzat1478 rzzat1478 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#include<stdlib.h>
#include<stdio.h>

static int comp(const void *a, const void *b)
{
return strcmp( * (const char ** )a,* (const char **) b);
}
void sortStrings(const char * array[])
{
int num;
for (num=0; array[num]; num++){};
qsort(array, num, sizeof( * array), comp) ;
}
main()
{
int i;
char *string[4]={"boy","girl","apple","dog"};
sortStrings(string);/*这行有错误*/
for(i=0;i<4;i++)printf("%d",string[i]);
system("Pause");
}
源代码如上,提示错误: [Warning] passing arg 1 of `sortStrings' from incompatible pointer type ,不知道为什么错?
...全文
评论 9
收藏 已收藏
分享
返回顶部
rzzat1478
C语言 70,040 成员 243,237 内容