在C中确定文件/文件夹 [英] Determine file/folder in C

查看:50
本文介绍了在C中确定文件/文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C语言中有以下代码:

I have the following code in C:

DIR *mydir = opendir("/");
struct dirent *entry = NULL;

while((entry = readdir(mydir)))
{
    printf("%s\n", entry->d_name);
    //printf("%i\n", entry->d_type);
}

closedir(mydir);

它可以正常工作并正确显示该位置的文件/文件夹.

It works and shows the files/folders in the location, correctly.

但是,我想知道它是文件夹还是文件.我怎样才能做到这一点?我尝试使用d_type(如您在代码中看到的),但没有成功.

However, I want to tell if it is a folder or a file. How can I do this? I tried with d_type (as you can see on the code) but no success.

推荐答案

使用

这篇关于在C中确定文件/文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆