getopt_long函数用法
来源:互联网 发布:小电影网站 知乎 编辑:程序博客网 时间:2024/05/22 03:13
getopt_long函数的原型如下:(#include<getopt.h>)getopt_long(int argc, char * const argv[], const char *optstring, const struct option *longopts,int *longindex);longopts是一个结构体类型,该结构体描述信息如下:struct option{const char *name; //the name of the long optionint has_arg; //no_argument(0); required_argument(1);optional_argument(2)int *flag; //NULL:return val;int val; //the value to return}具体的例子: #include<getopt.h> #include<stdio.h> const char *shortopt = "hi:"; struct option longopt[] = { {"help", 0, NULL, 'h'}, {"input", 1, NULL, 'i'} }; int main(int argc, char ** argv){int nextopt = getopt_long(argc, argv, shortopt, longopt, NULL);switch (nextopt){case 'h':printf("this is help option\n");break;case 'i':printf("the string you input is:\n%s\n",optarg);break;}return 0;}测试:./getopt_long -h./getopt_long -i "hello world"
0 0
- getopt_long函数用法
- getopt_long函数基本用法-linux
- getopt和getopt_long函数用法
- getopt函数与getopt_long函数的用法
- 命令解析函数getopt_long的用法
- Linux编程里getopt_long函数用法详解
- linux中函数getopt_long用法解释
- getopt_long 用法
- getopt_long用法
- getopt_long函数
- getopt_long函数
- C语言中getopt()和getopt_long()函数的用法
- getopt 函数 getopt_long函数
- getopt_long的用法
- getopt()和getopt_long()用法
- getopt_long用法及实例
- getopt_long()用法详解
- getopt()和getopt_long()用法
- 性能监控和分析工具--nmon
- wordpress 4.4 禁用REST API/移除wp-json链接的两种方法
- vs快捷键相关
- 哈理工hrbust OJ 2225 解题报告 【递推】
- 小满优品是一家总部设在大连高新区的文创电商企业
- getopt_long函数用法
- STL---哈希map:unordered_map
- 策略(Strategy)模式
- 塞尔将向阿里巴巴集团总裁迈克尔埃文斯汇报工作
- open-falcon alarm 模块报警信息处理
- 美团2015笔试题以及最优解(四)
- Base64的Java代码实现
- Vagrant+virtualBox搭建集成开发环境
- 值得说的一个问题:C语言实现拓扑排序