系统接口函数详解
1. alphasort 和 scandir 函数
1.1 函数概述
alphasort 和 scandir 函数用于扫描目录并对目录项进行排序。 alphasort 可作为 scandir 的比较函数,将目录项按字母顺序排序。
1.2 函数原型
#include <dirent.h>
int alphasort(const struct dirent **d1, const struct dirent **d2);
int scandir(const char *dir, struct dirent ***namelist,
int (*sel)(const struct dirent *),
int (*compar)(const struct dirent **, const struct dirent **));
1.3 函数描述
- alphasort :该函数通过对
dirent结构的d_name元素调用strcoll函数来实现排序。若strcoll失败,alphasort的返回值未指定。成功时,alphasort
超级会员免费看
订阅专栏 解锁全文
1万+

被折叠的 条评论
为什么被折叠?



