Is there any way to set argv and argc parameters in runtime?

reminder picture reminder · Dec 4, 2010 · Viewed 23.3k times · Source

I need to debug my program, the problem is that this program takes couple of parameters. How Can I debug program which takes a parameters ?? Can I somehow modify argc and argv parameters in runtime ??

Answer

Steve Townsend picture Steve Townsend · Dec 4, 2010

The best way is not to modify the arguments at runtime but to debug an instance that has the arguments you want.

For Windows you can do this in Visual Studio as follows:

  • Right click on project in Solution Explorer.
  • Set the arguments you want in Configuration Properties -> Debugging -> Command Arguments.
  • Hit F5 to start the program (after setting breakpoints where you want to stop).

Alternatively start the program up as normal from the command line, and attach the debugger afterwards.