1-17、讯为系统编程opendir和closedir

#include <stdio.h>
//opendir和closedir函数头文件
#include <dirent.h>
#include <sys/types.h>

int main(int argc,char *argv[])
{
	int ret;
	DIR *dir;
	
//检测参数	
	if(argc <2){
		printf("\nPlease input file path\n");
		return 1;
	}
//使用opendir函数打开目录
	dir = opendir(argv[1]);
	if(dir==NULL){
		printf("opendir %s failed!\n",argv[1]);
		return 1;
	}
	printf("opendir %s suceces!\n",argv[1]);
//使用closedir函数关闭目录
	closedir(dir);
	
	return 0;
}
发布了113 篇原创文章 · 获赞 1 · 访问量 1204

猜你喜欢

转载自blog.csdn.net/poor_guy_liu/article/details/103579141