2

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?

2
  • 1
    Does 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? Commented Oct 5, 2013 at 14:34
  • Thanks for questioning, I have fixed the problem. Commented Oct 5, 2013 at 15:06

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.