把握命运,追逐梦想

对自己所做的事要有兴趣,同时还要能够坚持不懈

统计

留言簿(1)

阅读排行榜

评论排行榜

qsort的用例

#include<stdio.h>
#include
<string.h>
#include
<stdlib.h>

int sort_func(const void*a,const void*b)
{
    
return (strcmp((const char*)a,(const char*)b));
}


int main()
{
    
char list[5][4= {"car","cat","cab","cap","can"};
    qsort((
void*)list,5,sizeof(list[0]),sort_func);
    
for(int i = 0; i <5++i)
    
{
        printf(
"%s",list[i]);
        printf(
"\n");
    }

    
return 0;
}

posted on 2009-07-28 16:39 把握命运 阅读(173) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理