Visual Studio doesn't open a DOS window when I

2019-09-21 00:35发布

问题:

I have setup everything. When I click Ctrl+F5, it does not show anything. I just want it to show my name with a black window. How do I do that?

回答1:

Most likely you have the subsystem set to "Windows application", which means the process will start with no console associated. Attempts to write will then fail.

You can either associate a console with AttachConsole() and/or AllocConsole() or change the subsystem via linker command line (/SUBSYSTEM:CONSOLE).



回答2:

Instead of running your program from within the development environment, open a Command Prompt window and navigate to the folder where the .exe is created and run it directly. That's how command-line programs are meant to be run.

If you have to run it in the development environment, perhaps for debugging, then put a breakpoint on the return or exit statement so it stops before the window is closed.