c - C - 如何在 getopts 中读取多个参数?
问题描述
我创建了一个 C 文件,它在处理一个参数时可以正常工作。如何在 getopts 中提取多个参数?
单参数运行良好:
test -c 3 -t 1101 -i 1S
我想阅读这样的多个论点:
test -c 3 -t 1101 1102 1103 -i 1S
下面是getops的代码:
struct option long_options[] =
{
{"testCase", required_argument, 0, 't'},
{"interval", required_argument, 0, 'i'},
{"cell", required_argument, 0, 'c'},
{"help", no_argument, 0, 'h'},
{0, 0, 0, 0}
};
optind = 0;
while (1)
{
int option_index = 0;
z = getopt_long(argc, argv, ":t:i:c:", long_options, &option_index)
...
解决方案
推荐阅读
- jquery - wordpress jquery .load(url + '#grabMe') 与视觉作曲家
- wordpress - 如何使用 add_action WordPress 更改值
- bar-chart - SSRS 2008R2 带聚合折线图的分组条形图
- java - 当我在android中取消选择1个复选框时如何取消选择全选复选框
- node.js - res.redirect 不是节点 js 请求方法中的函数
- makefile - Mac Mojave 上的 makefile '%' 通配符问题
- django - 我们如何保护 django python 文件以进行生产发布?
- javascript - 如何将数据表动态转换为树 json 格式?
- java - 如何修改/拆分数组中的单个字符串
- java - Class.forName 中的线程“主”java.lang.ClassNotFoundException 中的异常