linux遍历目录下的文件
来源:互联网 发布:移动公司网络维修电话 编辑:程序博客网 时间:2024/05/21 22:36
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
int main(int argc, char*argv[])
{
unsigned int loop=0;
char *dot= ".";
char *dotdot ="..";
DIR *dp;
struct dirent *dirp;
if(argc != 2)
{
printf("not enough arguments! exit!\n");
exit(0);
}
if((dp =opendir(argv[1]))== NULL)
{
printf("can't open %s!\n",argv[1]);
exit(0);
}
while((dirp = readdir(dp))!=NULL)
{
if( strcmp(dirp->d_name, dot)
&& strcmp(dirp->d_name, dotdot) )
{
printf("%d ,%s\n",dirp->d_off, dirp->d_name);
loop++;
}
}
closedir(dp);
printf("%u",loop);
}
#include <stdlib.h>
#include <sys/types.h>
#include <dirent.h>
int main(int argc, char*argv[])
{
unsigned int loop=0;
char *dot= ".";
char *dotdot ="..";
DIR *dp;
struct dirent *dirp;
if(argc != 2)
{
printf("not enough arguments! exit!\n");
exit(0);
}
if((dp =opendir(argv[1]))== NULL)
{
printf("can't open %s!\n",argv[1]);
exit(0);
}
while((dirp = readdir(dp))!=NULL)
{
if( strcmp(dirp->d_name, dot)
&& strcmp(dirp->d_name, dotdot) )
{
printf("%d ,%s\n",dirp->d_off, dirp->d_name);
loop++;
}
}
closedir(dp);
printf("%u",loop);
}
- linux遍历目录下的文件
- LINUX下目录文件的遍历---编程
- linux 遍历目录下的文件
- Linux下遍历目录下的文件 2
- linux 下遍历目录下的所有文件
- Linux下遍历目录下的所有文件
- C++实现Linux下遍历指定目录下的文件
- 遍历目录下的文件
- 遍历目录下的文件
- 遍历目录下的文件
- 自己写的一个LINUX 下目录文件遍历程序
- Linux C :遍历输出指定目录下的所有文件
- Linux C :遍历输出指定目录下的所有文件
- Linux C :遍历输出指定目录下的所有文件
- Linux C :遍历输出指定目录下的所有文件
- 递归遍历Linux下的目录文件源码实现
- Linux C :遍历输出指定目录下的所有文件
- 遍历目录,获取目录下的文件
- HDU 2680 最短路径
- 带下拉框的文本框
- HDU 3342 拓扑排序
- 05-防盗链技术
- HDU 1285 拓扑排序
- linux遍历目录下的文件
- 尼姆博弈
- 使用WinSetupFromUSB来U盘安装windowsXP
- 运用ifstream的getline时需要注意的问题
- POJ 3259 最短路径
- 使用ifstream和getline读取文件内容[c++]
- std::string用法总结
- shellcode编写技巧
- PYTHON 双引号 单引号 多引号区别