为什么我的输出只有在它之后有另一个打印时才打印? [英] Why does my output only print if there is another print after it?
本文介绍了为什么我的输出只有在它之后有另一个打印时才打印?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这里有趣的小错误:
if (host != NULL) {
printf("hi");
} else {
printf("FAIL");
}
return 0;
根本不打印任何东西,但是:
doesn't print anything at all, but:
if (host != NULL) {
printf("hi");
} else {
printf("FAIL");
}
fprintf(stdout, "\n%s\n", (char *)&additionalargs);
return 0;
印刷品
嗨
ABC
有人知道这是为什么吗?
Does anyone know why this is?
推荐答案
区别在于 \n 个字符.
The difference is the \n characters.
当您打印字符时,它们会累积在缓冲区中,该缓冲区在发送行尾"字符之前不会发送到输出设备.
As you printf characters, they are accumulated in a buffer which isn't sent to the output device until an 'end of line' character is sent.
这篇关于为什么我的输出只有在它之后有另一个打印时才打印?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文