C语言编程中有时会遇到一些参数个数可变的函数,例如printf()函数,其函数原型为: int printf( const char* format, ...); 它除了有一个参数format固定以外,后面跟的参数的个数和类型是可变的(用三个点“…”做参数占位符),实际调用时可以有以下的形式: printf("%d", i); printf("%s", s); printf("the number is %d ,string is:%s", i,
在编写shell脚本中,经常要处理一些输入参数,在使用过程中发现getopts更加方便,能够很好的处理用户输入的参数和参数值. getopts用于处理用户输入参数,举例说明使用方法: while getopts :a:b:cdefg opt; do case $opts in a) do sth; ...... cde) do another; esac done 几个重要变量: OPTIND:getopts使用OPTIND作为索引,