问题描述
有没有办法在 Visual Studio 中捕获标准输出和标准错误?例如,当我使用
Is there a way to catch the stdout and stderr in Visual Studio? For example, when I use
cout <<"Hello world!"<< endl;
一个黑色的窗口出现又消失.它太快了,我看不到它.IDE 中有一个输出部分,但它只允许我从构建和其他内容中选择显示输出,但不能选择标准输出.
A black window appears and disappears. It's so fast that I can't see it. There is a output section in the IDE but it only allow me to choose display output from build and something else but without the choice of stdout.
作弊解决方案可能会调用
A cheating solution maybe calling
system("pause");
但听起来不太对劲.我在选项中搜索,但找不到项目.
but it doesn't sound right. I searched in the option but I can't find an item.
有人知道吗?谢谢.我刚开始用VS,之前在Linux上.
Anyone has any idea? Thanks. I just start to use VS and I'm on Linux before.
推荐答案
不要使用Start Debugging"命令,如果要检查输出,请使用Start without Debugging".我一般都是这样处理的.命令提示符窗口将保持打开状态,直到您将其关闭.如果出现崩溃或其他情况,您始终可以将 Visual Studio 重新附加到该进程,或者只使用开始调试"运行它.
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".
这篇关于有没有办法在 Visual Studio 中捕获标准错误和标准输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!