I had this bite me in a certain sensitive spot this evening, and would like some clarification. As karlphillip said in this question, the executable sees the 开发者_如何学Goargument list as
Consider: ./program file.txt
argv[0] is "program"
argv[1] is "file.txt"
However, in the gdb debugger, for the program ./lc1 f1.txt
, the arglist shows as
arg[0] is "/home/jason/Project 6/lc1"
arg[1] is "lc1"
arg[2] is "f1.txt"
Why the discrepancy between the two arglists?
I can't reproduce that error. How are you running it on the gdb prompt?
I'm guessing you have
(gdb) run lc1 f1.txt
which is wrong. In the gdb prompt, it's supposed to be
(gdb) run f1.txt
That will reconcile with your normal execution.
精彩评论