简体   繁体   English

在VS2012中以调试模式运行时错误的命令参数

[英]Bad command arguments in VS2012 while running in debug mode

I keep getting wrong values in VS2012 from command arguments while in debug mode. 在调试模式下,我在VS2012中从命令参数中不断得到错误的值。 I've set the right arguments through Properties->Configuration properties->Debugging->Command Arguments, but I still get the same wrong output. 我已经通过Properties-> Configuration properties-> Debugging-> Command Arguments设置了正确的参数,但是我仍然得到相同的错误输出。

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 输出是:2130567168

Also, I've checked memory block where argv should be pointing at and it has nothing relevant to my passed arguments. 另外,我检查了argv应该指向的内存块,它与我传递的参数没有任何关系。

EDIT: 编辑:

I've fixed the problem thanks to doctorlove's questioning. 由于Doctorlove的询问,我已经解决了这个问题。 Apparently, setting the Entry Point produced the wrong value. 显然,设置入口点会产生错误的值。 I've had set it to "main" and removing it fixed the problem. 我已经将其设置为“ main”,并将其删除解决了该问题。

Can anyone explain why this happend? 谁能解释为什么会这样?

关于您的编辑,C程序的入口点不是main ,而是特定于C运行时的入口点,该入口点初始化C运行时,包括最终传递给main的参数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM