Debugging with command-line parameters in Visual S

2019-01-01 01:36发布

I'm developing a C++ command-line application in Visual Studio and need to debug it with command-line arguments. At the moment I just run the generated EXE file with the arguments I need (like this program.exe -file.txt) , but this way I can't debug. Is there somewhere I can specify the arguments for debugging?

8条回答
与风俱净
2楼-- · 2019-01-01 01:57

The Mozilla.org FAQ on debugging Mozilla on Windows is of interest here.

In short, the Visual Studio debugger can be invoked on a program from the command line, allowing one to specify the command line arguments when invoking a command line program, directly on the command line.

This looks like the following for Visual Studio 8 or 9

 devenv /debugexe 'program name' 'program arguments'

It is also possible to have an explorer action to start a program in the Visual Studio debugger.

查看更多
路过你的时光
3楼-- · 2019-01-01 02:01

In Visual Studio 2010, right click the project, choose Properties, click the configuring properties section on the left pane, then click Debugging, then on the right pane there is a box for command arguments.

In that enter the command line arguments. You are good to go. Now debug and see the result. If you are tired of changing in the properties then temporarily give the input directly in the program.

查看更多
呛了眼睛熬了心
4楼-- · 2019-01-01 02:02

Microsoft Visual Studio Ultima 2013.

You can just go to the DEBUG menu → Main PropertiesConfiguration propertiesDebugging and then you will see the box for the command line arguments.

Actually, you can set the same input arguments for all the different configurations and not only for debugging.

From the pull down menu of configuration select: All Configurations and insert the input arguments (each argument separated by space).

Now, you can execute your program in different modes without having to change the input arguments every time.

查看更多
柔情千种
5楼-- · 2019-01-01 02:08

Right click on the Project in Solution window of VS, select "Debugging" (on the left side), enter the arguments into the field "Command Arguments":

enter image description here

查看更多
梦寄多情
6楼-- · 2019-01-01 02:09

Yes, it's on the Debugging section of the properties page of the project.

In VS since 2008: right-click the project, choose properties, go to the Debugging section -- there is a box for "Command Arguments". (Tip: not solution, but project)

查看更多
谁念西风独自凉
7楼-- · 2019-01-01 02:09

This may help some people who still have problems. I use Visual Studio 2015 and I could only pass the arguments when I changed the definition of argv.

Instead of

int main(int argc, char **argv){
}

I had to use

int main(int argc, char *argv[]){
}

I do not know why it was necessary, but it works.

查看更多
登录 后发表回答