在C中实现了我的ls -R问题。当我使用命令运行程序时./myls -R无显示,全部为空白:(需要帮助。
int print_Recursive(char *dirname)
{
char fbuf [256];
DIR *dir;
struct dirent *dirp;
struct stat sbuf;
printf("\n");
dir = opendir(dirname);
while ((dirp = readdir(dir)))
{
if(strcmp(dirp->d_name, ".") != 0 &&
strcmp(dirp->d_name, "..") != 0)
{
sprintf(fbuf, "%s/%s", dirname, dirp->d_name);
}
}
closedir(dir);
return 0;
}
int print_file(char *file, char *dir, struct stat buf, int showinode, int showlong, int showRec)
{
if (showinode)
printf("%lld ", buf.st_ino);
if (showlong)
print_long(file, dir, buf);
if (showRec)
print_Recursive(dir);
else
printf("%s\n", file);
return 0;
}
无法弄清楚我做错了什么:(