linux c getopt
来源:互联网 发布:ios AFN上传图片数组 编辑:程序博客网 时间:2024/06/08 16:25
while ((c = getopt(argc, argv, "mtThfFdvVqprRgciInx:U:G:C:L:M:e:s:WB")) != -1) {
switch (c) {
冒号表示选项带参数 存放在optarg变量中
当给定getopt()命令参数的数量 (argc
)、指向这些参数的数组 (argv
) 和选项字串 (optstring
) 后,getopt()
将返回第一个选项,并设置一些全局变量。使用相同的参数再次调用该函数时,它将返回下一个选项,并设置相应的全局变量。如果不再有可识别的选项,将返回-1
,此任务就完成了。
getopt()
所设置的全局变量包括:
char *optarg
——当前选项参数字串(如果有)。int optind
——argv的当前索引值。当getopt()在while循环中使用时,循环结束后,剩下的字串视为操作数,在argv[optind]至argv[argc-1]中可以找到。- int opterr——这个变量非零时,getopt()函数为“无效选项”和“缺少参数选项,并输出其错误信息。
int optopt
——当发现无效选项字符之时,getopt()函数或返回'?'字符,或返回':'字符,并且optopt包含了所发现的无效选项字符。
- linux c getopt
- linux c getopt getopt_long
- linux c/c++中getopt的使用
- linux:getopt
- linux getopt
- Linux <getopt>
- getopt.cygwin.c,来自cygwin的getopt
- c getopt函数用法
- C函数getopt使用
- C语言-getopt函数
- C语言 getopt()函数
- C语言getopt()函数
- C语言getopt()函数
- getopt 详解 linux
- [Linux]getopt() 函数介绍
- getopt under Linux
- getopt 详解 linux
- Linux选项-getopt/getopt_long
- NSUndoManager
- 介绍几款本人使用的usb转串口芯片
- JSplitPane
- Collapsible GridView in ASP.Net 2.0
- mysql——timestamp和datetime格式
- linux c getopt
- SQL语句导入导出大全
- linux c getopt getopt_long
- shell递归实文件内容过滤
- Spring学习文档_IOC配置与应用
- nchar,char,varchar与nvarchar区别
- 域名注册
- XML文件定义DTD
- Semi-supervised learning