I keep getting wrong values in VS2012 from command arguments while in debug mode. I've set the right arguments through Properties->Configuration properties->Debugging->Command Arguments, but I still get the same wrong output.
The code works in release mode, but not in debug mode.
Here is my code:
int main(int argc, char **argv)
{
cout << argc << endl;
return 0;
}
Output is: 2130567168
Also, I've checked memory block where argv should be pointing at and it has nothing relevant to my passed arguments.
EDIT:
I've fixed the problem thanks to doctorlove's questioning. Apparently, setting the Entry Point produced the wrong value. I've had set it to "main" and removing it fixed the problem.
Can anyone explain why this happend?
-
1Does the debug version have generate debug info set? Does it behave the same from a command prompt? Is that all there is in your program? What have you set the command args to? Does a rebuild fix it?doctorlove– doctorlove2013年10月05日 14:34:50 +00:00Commented Oct 5, 2013 at 14:34
-
Thanks for questioning, I have fixed the problem.Masa– Masa2013年10月05日 15:06:08 +00:00Commented Oct 5, 2013 at 15:06
1 Answer 1
Regarding your edit, the entry point of a C program is not main, but a C runtime-specific entry point that initializes the C runtime, including the arguments that are eventually passed to main.
Comments
Explore related questions
See similar questions with these tags.