#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
int main(int argc,char *argv[])
{
struct stat st;
printf("%s",argv[1]);
stat(argv[1],&st);
if (S_ISDIR(st.st_mode))
printf("is a dir\n");
else
printf("is not a dir\n");
return 0;
}
虚拟机上测过了.
是验证输入的第一个参数是不是目录.
温馨提示:答案为网友推荐,仅供参考