显示进度指示器
我在 Linux 中使用 C。如何显示进度指示器,让我知道程序(或程序的一部分)何时完成?例如,它可能类似于“正在搜索...67%”,并且百分比将不断增加,直到搜索部分结束。
谢谢。
I'm using C in Linux. How do I show a progress indicator that will let me know when the program (or parts of the program) will complete? For example, it could be something like "Searching...67%" and the percentage will keep increasing until the Searching portion ends.
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将
'\r'
字符写入 stdout 以使光标返回到行的开头,以便您可以覆盖该行。例如:Write a
'\r'
character to stdout to return the cursor to the beginning of the line so you can overwrite the line. For example:我相信如果您执行以下操作:
fflush()
对于避免行缓冲是必要的。请注意,我使用的是\r
而不是\n
。I believe if you do something like:
the
fflush()
is necessary to avoid the line buffering. Note that I am using\r
and not\n
.