krisfrajer
June 21st, 2009, 05:02 PM
Hi all
I need some help trying to understand the manipulation of arguments for a c++ program. From my tests, I have figured out that my program is not the problem but it looks like the current shell is discarding arguments...
Let me explain my problem in an example.
What I am trying to do is to pass a filename as argument to my program.
I execute the following line
./bin/APIanalyzer APIanalyzer.vmemac 11 22
However when I read the argument list in my c++ code I get
total argumnets 3
argv[3] is 22
argv[2] is 11
argv[1] is./bin/APIanalyzer
As you notice, the APIanalyzer.vmemac argument was discarded. Remark:APIanalyzer.vmemac is a file that exists in my current directory!!!
I did the same test by inputting a filename that does NOT exist in my current directory:
./bin/APIanalyzer APIanalyzer.v 11 22
Then when I read the list of arguments I get:
argv[4] is 22
argv[3] is 11
argv[2] is APIanalyzer.v
argv[1] is./bin/APIanalyzer
Any suggestions what could be causing this problem? From my point of view, it looks like the executing shell discards any filename parameters if that filename exists.
I appreciate your comments...
Cheers,
I need some help trying to understand the manipulation of arguments for a c++ program. From my tests, I have figured out that my program is not the problem but it looks like the current shell is discarding arguments...
Let me explain my problem in an example.
What I am trying to do is to pass a filename as argument to my program.
I execute the following line
./bin/APIanalyzer APIanalyzer.vmemac 11 22
However when I read the argument list in my c++ code I get
total argumnets 3
argv[3] is 22
argv[2] is 11
argv[1] is./bin/APIanalyzer
As you notice, the APIanalyzer.vmemac argument was discarded. Remark:APIanalyzer.vmemac is a file that exists in my current directory!!!
I did the same test by inputting a filename that does NOT exist in my current directory:
./bin/APIanalyzer APIanalyzer.v 11 22
Then when I read the list of arguments I get:
argv[4] is 22
argv[3] is 11
argv[2] is APIanalyzer.v
argv[1] is./bin/APIanalyzer
Any suggestions what could be causing this problem? From my point of view, it looks like the executing shell discards any filename parameters if that filename exists.
I appreciate your comments...
Cheers,