我正在使用Microsoft Visual Studio做C ++。
我在IDE的输出控制台中看不到std :: err和std :: out。
有没有办法重定向他们?
最佳答案
您确实可以重定向std :: out和std :: err。只需在解决方案资源管理器中右键单击您的项目,然后选择Properties
。然后选择Configuration Properties -> Debugging
并将适当的参数放入Command Arguments
字段。例如,要将std :: err重定向到文件,我将输入2> ErrorLog.txt
。
在Visual Studio运行程序时,您在Command Arguments
中键入的内容仅作为命令行参数附加,就像您在控制台中手动键入它们一样。因此,以上示例仅告诉VisualStudio使用命令<programName>.exe 2> ErrorLog.txt
而不是<programName>.exe
运行您的程序。
关于visual-studio - 将stdout和stderr重定向到Microsoft Visual Studio的输出调试控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2683249/