我正在传递程序输入,我可以在argv中看到它们,但getopt似乎没有我期望的参数。
这是我运行程序的方式:./my_prog -X -f filename
<snip>
while ((opt = getopt(argc, argv, "Xf:eE:dD")) != EOF) {
switch (opt) {
case 'X':
case 'f':
if (optarg == NULL)
fput("no point of living", fp); << for debugging
</snip>
我总是得到空的optarg。为什么?
-X
还是-f
的调试信息? - mu is too short-f
而不是来自-X
的穿透吗? - mu is too short