C程序列出目录中的文件
2021-07-07 10:08:55
深夜i
--
--
C
程
序
列
出
目
录
中
的
文
件
C 程序来列出目录/文件夹中存在的所有文件,其中存在其可执行文件。 例如,如果可执行文件存在于 C:\\TC\\BIN 中,那么它将列出 C:\\TC\\BIN 中存在的所有文件。
C 程序(仅限 Turbo C 编译器)
#include <stdio.h>
#include <conio.h>
#include <dir.h>
int main()
{
int done;
struct ffblk a;
printf("Press any key to view the files in the current directory\n");
getch();
done = findfirst("*.*", &a, 0); // The first '*' is for all file names and the second one is for all file extensions
while(!done)
{
printf("%s\n", a.ff_name);
done = findnext(&a);
}
getch();
return 0;
}
当您在计算机上执行程序时,您将获得不同的输出。
上一篇:
idea打包java可执行jar包
下一篇:
C程序删除文件
评论区