Debugging with command-line parameters in Visual Studio

前端 未结 9 1821
误落风尘
误落风尘 2020-11-22 14:52

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 ar

相关标签:
9条回答
  • 2020-11-22 15:40

    Right click on the project in the Solution window of Visual Studio, select "Debugging" (on the left side), and enter the arguments into the field "Command Arguments":

    0 讨论(0)
  • 2020-11-22 15:42

    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.

    0 讨论(0)
  • 2020-11-22 15:42

    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.

    0 讨论(0)
提交回复
热议问题