LinuxDriver/Linux系统编程篇/02目录IO/openAndCloseDir.c

26 lines
403 B
C
Raw Normal View History

2025-07-14 01:38:46 +08:00
#include <stdio.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <dirent.h>
int main(int argc, char *argv[])
{
int ret;
DIR *dp;
if (argc !=2){
printf("Usage:%s <name file>\n", argv[0]);
return -1;
}
dp = opendir(argv[1]);
if (dp !=NULL){
printf("opendir is ok\n");
return -1;
}
closedir(dp);
printf("opendir is closed\n");
return 0;
}