在调试时查看文件输出 [英] view file output while debugging

查看:162
本文介绍了在调试时查看文件输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在调试模式下将输出重定向到文件的问题是,在程序完成之前,我无法查看文件的内容(大小为零)。有这个用法:

  FILE * f; 
f = fopen(log.txt,w);
fprintf(f,cycle =%d\\\
,c);

当我正在调试时,我想在步进后立即查看文件cycle =输出fprintf语句。



有什么办法吗?

解决方案>

您可以尝试在 fprintf()函数调用后放入 fflush(f); 数据将立即写入。


The problem with redirecting the output to a file in debug mode is that I can not view the content of file (size is zero) until the program finish. With this usages:

FILE *f;
f = fopen("log.txt", "w");
fprintf(f, "cycle =%d\n", c);

while I am debugging, I want to view the track "cycle =" in the file right after stepping out "fprintf" statement.

Is there any way to do that?

解决方案

You can try to put fflush(f); after fprintf() function call, which will make the data be written immediately.

这篇关于在调试时查看文件输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆