getopt()是比较简易的分析命令行参数的函数,可以参考下面的例子修改得到。

http://www.gnu.org/s/libc/manual/html_node/Example-of-Getopt.html#Example-of-Getopt