c++ - 在 C++/C 中通配,在 Windows 上

标签 c++ c windows glob

在 Windows 中是否有一种流畅的方式在 C 或 C++ 中进行 glob?

例如,myprogram.exe *.txt 向我的程序发送一个 ARGV 列表,其中包含...ARGV[1]=*.txt

我希望能够有一个函数(我们称之为 readglob),它接受一个字符串并返回一个字符串 vector ,每个字符串都包含一个文件名。

这样,如果我的目录中有文件 a.txt b.txt c.txt 并且 readglob 得到一个参数 *.txt,它会返回上面的文件列表.

//Prototype of this hypothetical function.
vector<string> readglob(string);

这样的存在吗?

最佳答案

setargv.obj(或 wsetargv.obj)的链接和 argv[] 将为您提供类似于 Unix shell 的方式:

我无法保证它的效果如何。

关于c++ - 在 C++/C 中通配,在 Windows 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1269480/

相关文章:

c++ - 算法运行时间

c++ - 一种通过 ID 访问并查找加权随机项的高效数据结构

c - 抑制 R 中的 C 警告消息

windows - 为什么在 Windows Vista x64 上调用 GlobalMemoryStatus 时可用物理内存 (dwAvailPhys) > 可用虚拟内存 (dwAvailVirtual)

windows - 如何制作虚幻引擎 4 全屏(Windows 包)

c++ - 函数运行时间

c++ - 打开 GL : is this the right way of using VBO IBO and VAO

c - 堆栈内存有限制吗?

c - 非子进程上的非 root ptrace/waitpid

java - 在 java 代码中运行 .exe 文件