Piping input into a c++ program to debug in Visual Studio

前端 未结 2 1638
梦如初夏
梦如初夏 2020-12-09 04:17

this has probably been asked before, but I haven\'t been able to find any answers so far. I\'m trying to start my program up with multi-line input, I.E. something I don\'t w

2条回答
  •  借酒劲吻你
    2020-12-09 04:59

    Put your data in a file then go to the project properties in Visual Studio and select the "Debugging" category.

    In the "Command Arguments" property type:

    < "path/to/the/file"
    

    Now that file will be fed to the program via standard input when the debugger is launched or when you launch the program within Visual Studio (but without the debugger) using Ctrl-F5.

    You can use VS macros to specify the project directory, etc. if you want the test file to move along with the project.

提交回复
热议问题