1 / 3
文档名称:

C语言alphasort()函数.doc

格式:doc   大小:24KB   页数:3页
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

C语言alphasort()函数.doc

上传人:changjinlai 2020/2/2 文件大小:24 KB

下载得到文件列表

C语言alphasort()函数.doc

文档介绍

文档介绍:C语言alphasort()函数:依字母顺序排序目录结构相关函数:scandir,qsort头文件:#include<>定义函数:intalphasort(conststructdirent**a,conststructdirent**b);函数说明:alphasort()为scandir()最后调用qsort()函数时传给qsort()作为判断的函数,详细说明请参考scandir()及qsort().返回值参考qsort()。范例/*读取/目录下所有的目录结构,并依字母顺序排列*/#include<>main(){  structdirent**namelist;  inti,total;  total=scandir("/",&namelist,0,alphasort);  if(total<0)    perror("scandir");  else  {    for(i=0;i<total;i++)    printf("%s\n",namelist[i]->d_name);    printf("total=%d\n",total);  }}执行:...+foundmiscmntoptprocrootsbintmpusrvartotal=24