![](https://csdnimg.cn/release/download_crawler_static/86985304/bg4.jpg)
HRBUST
哈尔滨理工大学计算机科学与技术学院
《UNIX/Linux 程序设计》课程设计报告
stat 可用来获取文件的权限 (man 2 stat 察看),stat 结构体如下:
其中: st_mode 即是文件的权限
5.判断是不是目录文件 S_ISDIR
int S_ISDIR(mode) //是否是一个目录
6.判断是不是普通文件 S_ISREG
int S_ISREG(mode) //是否是一个常规文件
7.检查文件存在性 access
Int access(const char *filename, int amode)
//amode 的参数为 0 时表示检查文件的存在性,如果文件存在,返回 0,不存在,返回
-1.
8.字符串比较函数 strcmp
原型:extern int strcmp(const char *s1,const char * s2);
用法:#include <string.h>
功能:比较字符串 s1 和 s2。
一般形式:strcmp(字符串 1,字符串 2)
2