简体   繁体   中英

Easy way to run command line programs C++ - Windows 7

I am trying to find an easier way to test my command line application. It has arguments so I run it from a command prompt. My process is this:

  1. Build
  2. Go to the output
  3. Open command prompt
  4. Change directory
  5. Run it

There has to be an easier way not only to debug but to open a command prompt in the current folder.

Thank you for your time.

If you go to the project properties, Debugging settings, you can set the working directory and parameters. If you use the same parameters all of the time, you can enter those in on that screen as well. Then just F5 or Ctrl+F5 to run.

Set a breakpoint at the end of the code to keep it from going away after it is done.

See Debugging with command-line parameters in Visual Studio

Alternatively, you should be able to use a shell script (or Python os.system() ) to automate some of those steps.

To open a command prompt in the current directory using explorer, you can shift+right click->Open Command Window Here. That will save a little time.

If you're using Visual Studio, pressing F5 will run the code in the debugger, and Ctrl+F5 will run the code normally. Just remember to include a cin.get() statement at the end or the terminal window will close before you can read the output.

Other IDEs should have similar functions. Check in the Run or Debug menu.

EDIT: Sorry, didn't see that you're asking about running it with arguments. In VS, in Project Properties there are the Debugging settings. Within that, there is a field called Command Arguments. These will get passed to the application when you run it from within VS.

在调试中的项目属性中,可以在调试时设置命令行参数(和环境变量),

There is an extension called PowerCommands for Visual Studio 2010 that can be installed from Tools -> Extension Manager . It includes a Open Containing Folder and Open Command Prompt functionality that gets added to your right-click menu in the Solution Explorer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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