Code 上面代码在VC6和VC9下编译通过,在命令行下输入:getopt -a -b -c5 9 结果显示 option a option b option c with value `5' non-option ARGV-elements: 9 怎么样?happy吧 O(∩_∩)O~ 也许有朋友会问:我在Win32程序中也可以使用它么? 其实不用担心,stdlib.h中为我们准备了两个好东
2. 然后我们定义一个结构体,在后面这个结构体会被getopt_long()解析(注意常用的是getopt_long,因为它同时支持长短选项)。 1 2 3 4 5 6 7 8 9 10 11 int opt; static struct option long_options[] = { {"help", 0, 0, '?'}, {"check", 0, 0, 'c'}, {"bench", 1, 0, 'b'}, {"...
这将帮助你,如果你想端口一个已知的实用程序,已经使用argp。如果你是从头开始写,你可以使用glib(C)...
http://ieng6.ucsd.edu/~cs12x/vc08install/getopt9.zip 把压缩文件中的getopt.h头文件和getopt.lib库文件拷贝到你的计算机中,然后添加这些目录到VC++搜索路径中,以至于getopt库可以像标准库的一部分使用。 注:在CodeProject网站上也提供基于C的GetOpt库实现,下载网址为: http://www.codeproject.com/Articles/1...
使⽤getopt函数对windows命令⾏程序进⾏参数解析getop t()是libc的标准函数,很多语⾔中都能找到它的移植版本。// -b -p "c:\input" -o "e:\test\output"bool bBinary = false;char szPath[MAX_PATH] = {0};char szOput[MAX_PATH] = {0};int c = 0;while ((c = getopt(argc, argv,...
解决方法是从http://directory.fsf.org/选择Software Development,然后选择GNU C的标准库,找到getopt源码,然后放到VC里编译一下,真的没别的办法
getopt在win32、64位环境下都是可以使用,只要包含stdlib.h,使用_argc,__argv两个参数即可,下面示例:int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){ Test(__argc,__argv);return 0;} 上面的代码同样适用于BCB6。
This library was created to allow compilation Linux-based software on Windows.http://en.wikipedia.org/wiki/Getopt The sources were taken from MinGW-runtime project. AUTHORS: Todd C. MillerTodd.Miller@courtesan.com The NetBSD Foundation, Inc. ...
wingetopt getopt library for Windows compilers This library was created to allow compilation Linux-based software on Windows.http://en.wikipedia.org/wiki/Getopt The sources were taken from MinGW-runtime project. AUTHORS: Todd C. MillerTodd.Miller@courtesan.com ...
GNU libc提供了getopt和getopt_long用于解析命令行参数,使用方便,但是windows环境没有提供。故将GNU libc提供的源码稍加修改,整理出了windows下可用的getopt和getopt_long。 参数解析 c语言 c++2018-09-06 上传大小:7KB 所需:44积分/C币 一个修仙岛的规划方案-公园广场景观CAD平面方案立面节点大样施工图.zip ...