views:

19122

answers:

4

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?

+34  A: 

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

In VS 2008, right click the project, choose properties, go to the Debugging section -- there is a box for command line arguments.

Lou Franco
Thanks, that was quick!
maciej.gryka
Funny how a search of Visual Studio help finds about 55,000 irrelevant matches; but google puts this thread second from the top... Thank You! Thank You! and Thank You!
corlettk
Worked well for me too... thx
Kyle B.
And me. Thanks.
Pauk
Borgenk
+2  A: 

Even if you do start the executable outside Visual Studio, you can still use the "Attach" command to connect Visual Studio to your already-running executable. This can be useful e.g. when your application is run as a plug-in within another application.

MSalters
+5  A: 

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.

grrussel
+1  A: 

Just for those who encounter the same problem as I had. I could not pass parameters while debugging in Visual C++ even tough after checking this post. The thing was in fact quite stupid, the project with the "main" file was not set as start-up project- (Dough!) That solve the problem.

Julen