通配符在C ++ / C,在Windows [英] Globbing in C++/C, on Windows
问题描述
有没有的流畅的方式在C或C ++在Windows glob的到?
Is there a smooth way to glob in C or C++ in Windows?
如,myprogram.exe * .TXT发送我的程序,有一个argv列表... ARGV [1] = *。txt的
在里面。
E.g., myprogram.exe *.txt sends my program an ARGV list that has...ARGV[1]=*.txt
in it.
我希望能够有一个函数(让我们称之为readglob)采用一个字符串并返回一个字符串矢量,每个包含一个文件名。
I would like to be able to have a function (let's call it readglob) that takes a string and returns a vector of strings, each containing a filename.
这样,如果我在我的目录中的文件 A.TXT b.txt c.txt
和readglob得到一个说法 *。txt的
,它返回上面的文件列表。
This way, if I have files a.txt b.txt c.txt
in my directory and readglob gets an argument *.txt
, it returns the above filelist.
//Prototype of this hypothetical function.
vector<string> readglob(string);
这样是否存在?
推荐答案
链接与 setargv.obj
(或 wsetargv.obj
)和argv []将晶片被你类似Unix外壳是如何做到这一点:
Link with setargv.obj
(or wsetargv.obj
) and argv[] will be globbed for you similar to how the Unix shells do it:
我不能保证它,以及它如何虽然。
I can't vouch for how well it does it though.
这篇关于通配符在C ++ / C,在Windows的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!