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 argument 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
which is wrong. In the gdb prompt, it's supposed to be
That will reconcile with your normal execution.