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.