Is there a way to catch the stderr and stdout in Visual Studio?

懵懂的女人 提交于 2019-11-30 17:24:37

Rather than using the "Start Debugging" command, if you want to check the output, use "Start Without Debugging". That's generally how I handle it. The command prompt window will remain up until you close it. If there's a crash or something, you can always reattach Visual Studio to the process, or just run it with "Start Debugging".

Go to Project Properties -> Linker -> System -> Change subsystem to Console.

Without actually trying to redirect stdin/err streams, there are some alternatives you can try:

  • Open a command prompt window and cd to the directory your executable will be created in then run it from there.
  • Perhaps try using something like std::cin.get(); or std::cin.ignore(std::cin.rdbuf()->in_avail() + 1); instead of system("pause").
  • Display output in the visual studio debugger via OutputDebugString
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!