终端上不打印单个字符 [英] Single characters are not printed on the terminal

查看:56
本文介绍了终端上不打印单个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有 3 个不同的进程,它们都使用 printf 打印出单个字符.但是我在终端看不到它们.当我添加换行符时,printf("\n H") 所以每个字符都在一个新行上,我可以看到它们.为什么没有换行符就不行?

I have 3 different processes that all print out single characters using printf. But I can't see them in the terminal. When I add a newline, printf("\n H") so each character is on a new line, I can see them. Why doesn't it work without the newline character?

推荐答案

这是冲洗的问题.如果你在每个 printf 之后刷新缓冲区,你应该得到更接近你想要的输出.要刷新标准输出,只需执行 fflush( stdout ).

Its a matter of flushing. If you flush the buffers after each printf, you should get output closer to what you want. To flush the standard output simply do fflush( stdout ).

这篇关于终端上不打印单个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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