ChinaUnix.net
相关文章推荐:

optarg,optind

感觉gdb不大好用 程序可以正常运行,但这两个变量确一直是初始值,比如optind=1,optarg=0; 必须要事先把他们声明为全局变量才可以吗? 是不是还有会有多类似问题出现 或者是我gdb用的还不熟悉,导致了此类情况出现 请高手赐教

by ieangel - C/C++ - 2006-10-27 17:41:55 阅读(1509) 回复(0)

相关讨论

俺是SHELL菜鸟,这几天看了新手导航版块里waker 介绍的帖子。 其中设计到$optind的问题一直没弄明白,不知道具体$optind的值是如何递增的。 在cuci大大的文章http://bbs.chinaunix.net/viewthread.php?tid=557642中有如下代码 #--拷贝程序   COPIES=1   VERBOSE=N   while getopts vc:OPTION   do     case $OPTION     in       c)COPIES=$optarg;;       v)VERBOSE=Y;;       \?)e...

by soulless - Shell - 2012-05-27 07:11:20 阅读(4376) 回复(5)

i use while getopts :d:f:F:i:n:O: OPT do done $optarg is empty .调用的时候传的参数取不到

by fufelixzh - Shell - 2012-02-21 22:10:24 阅读(1405) 回复(2)

怎么样让getopts命令的内置变量optarg能得到{1..100}扩展后的所有值.测试了一下它总是只能得到扩展后的第一个值,在这里optarg的值为1.

by kvkingdom - Shell - 2009-03-29 11:45:37 阅读(3744) 回复(6)

getopt实用的 char *string=optarg; error: syntax error before "char" 不能这样吗? [ 本帖最后由 darkslack 于 2007-9-20 14:07 编辑 ]

by darkslack - C/C++ - 2007-09-20 14:29:36 阅读(3196) 回复(5)

[code][root@GO-EMAIL-1 ~]# cat 1.sh #!/bin/bash echo $* while getopts "ab:cd:" Option # b and d take arguments # do case $Option in a) echo -e "a = $optind";; b) echo -e "b = $optind $optarg";; c) echo -e "c = $optind";; d) echo -e "d = $optind $optarg";; esac done shift $(($optind - 1)) [root@GO-EMAIL-1 ~]# sh 1.sh -ab foo -ab foo a = 1 b = 3 foo [/code]1.-ab是如何理解的,是一个option还是2个optio...

by todayhero - Shell - 2013-12-22 21:07:42 阅读(3908) 回复(3)

[code]while((opt = getopt(argc, argv, "o:a:s:")) != EOF) { switch(opt) { case 'o': offset = atoi(optarg); break; case 'a': align = atoi(optarg); break; case 's': server = (char *)malloc(strlen(optarg) + 1); server = optarg; break; default: usage(argv[0]); break; }[/code] 编译时总是提示optarg没有定义,是要自己来写吗?但是...

by fwizard - C/C++ - 2008-07-19 00:24:10 阅读(13016) 回复(7)

[code] while getopts ":abcde:fg" Option # Initial declaration. # 开始的声明. # a, b, c, d, e, f, 和 g 被认为是选项(标志). # e 选项后边的:提示,这个选项带一个参数. do case $Option in a ) # Do something with variable 'a'. echo aaa ;; b ) # echo bbb ;; e) # Do something with 'e', and also with $optarg, echo eee with $optarg ;; g ) # 对选项'g'作些操作. echo ggg ;; esac done shift $(($optind - 1)) # 将参...

by Ray001 - Shell - 2006-11-12 10:40:08 阅读(5549) 回复(4)

请问各位大侠opind参数的含义。

by xiechunlu - C/C++ - 2006-08-16 10:23:42 阅读(1221) 回复(1)

The variable optind is the index of the next element to be processed in argv. The system initializes this value to 1. The caller can reset it to 1 to restart scanning of the same argv, or when scanning a new argument vector. If getopt() finds another option character, it returns that character, updating the external variable optind and a static variable next...

by kggg - C/C++ - 2009-11-18 11:48:54 阅读(1459) 回复(1)

有这样一个关于optind的脚本,运行后发现optind分别是1,3,5,请教大家,这是为什么呢? 脚本: #!/bin/sh # test_getopts while getopts "xy:z:" name do echo "$name" $optind $optarg done 执行: test_getopts -xy 110 -z 220 结果: x 1 y 3 110 z 5 220

by reneyangs - Shell - 2007-04-06 12:41:59 阅读(1456) 回复(0)