#include <sys/types.h>
#include <dirent.h>
int main(int argc, char* argv[])
{
DIR* lpoDir;
struct dirent* lpoDirent;
if ( 2 != argc)
{
printf("a single argument (the directory name) is required");
return -1;
}
if ( (lpoDir = opendir(argv[1])) == NULL)
{
printf("can't open %s", argv[1]);
return -1;
}
while ( (lpoDirent = readdir(lpoDir)) != NULL)
printf("%s\n", lpoDirent->d_name);
closedir(lpoDir);
return 0;
}
LinuxC模拟ls程序
最新推荐文章于 2022-11-04 19:13:00 发布