如何将程序的打印结果显示在visual studio里?

zzxian 2011-05-18 04:58:51
用过eclipse的同行都知道:eclipse在调试程序的时候把控制台程序的打印到屏幕结果重定向到了eclipse IDE中了。这样做很方便我们调试程序。
但是我使用visual studio 2008调试c++控制台程序时,却是弹出了控制台的黑框。每次想看结果都要在main函数退出前加上system("pause"),这样很麻烦。
请问如何设置visual studio才能把打印信息重定向到vs中呢? 在线等答案!
...全文
1391 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
BrandBoy 2011-05-27
  • 打赏
  • 举报
回复
std::cout << "" << std::endl;
ljt3969636 2011-05-21
  • 打赏
  • 举报
回复
print怎么用TRACE宏就怎么用
logiciel 2011-05-21
  • 打赏
  • 举报
回复
选择项目的property->Configuration Properties->Build Events->Post-Build Event
在右方窗口的Command Line栏中输入执行exe文件的命令,即带全路径的exe文件名。这样build结束后自动执行该程序,程序输出在VS的output窗口。

参考:
If you run the console app in the post build step it's output will go to the output window. The inability to do this easily has been on of my biggest peeves with VS (any version)

http://stackoverflow.com/questions/194436/how-do-you-run-a-console-application-in-the-visual-studio-output-window-instead
GARY 2011-05-21
  • 打赏
  • 举报
回复
TRACE
printf
logiciel 2011-05-21
  • 打赏
  • 举报
回复
http://stackoverflow.com/questions/2518509/redirect-console-write-methods-to-visual-studios-output-window-while-debuggin

Redirect Console.Write… Methods to Visual Studio's Output Window While Debugging
ryfdizuo 2011-05-18
  • 打赏
  • 举报
回复
mfc下知道TRACE,
zzxian 2011-05-18
  • 打赏
  • 举报
回复
OutPutDebugString将字符串输入到了debugger中了。
我还是想把程序运行时的打印结果重定向到vs中,vs真的没有这个功能吗?
白云飘飘飘 2011-05-18
  • 打赏
  • 举报
回复
记错了, 用3楼的OutputDebugString,在VS中高调时会把内容打印到vs的输出窗口中
白云飘飘飘 2011-05-18
  • 打赏
  • 举报
回复
记错了,这个是驱动里面用的,用3楼的,用outputdebugstring在调试时会把内容打印出vs的输出窗口
zzxian 2011-05-18
  • 打赏
  • 举报
回复
lhcwjy 能具体点吗?
c_losed 2011-05-18
  • 打赏
  • 举报
回复
OutputDebugString
zzxian 2011-05-18
  • 打赏
  • 举报
回复
结贴率0%,是因为这个账号今天刚提问了两个问题,现在没有合适答案,没有结贴。请大家不吝赐教,帖子我会尽快结掉的。
白云飘飘飘 2011-05-18
  • 打赏
  • 举报
回复
dbgprint

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧