打印纺纱光标用C终端运行的应用程序 [英] Print spinning cursor in a terminal running application using C

查看:128
本文介绍了打印纺纱光标用C终端运行的应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么会在一个终端使用标准的C运行的实用打印纺纱光标?

How would I print a spinning curser in a utility that runs in a terminal using standard C?

我在寻找的东西打印:\\ | /? - 在屏幕上的同一位置反复

I'm looking for something that prints: \ | / - over and over in the same position on the screen?

感谢

推荐答案

您可以使用退格键( \\ b )是这样的:

You could use the backspace character (\b) like this:

printf("processing... |");
fflush(stdout);
// do something
printf("\b/");
fflush(stdout);
// do some more
printf("\b-");
fflush(stdout);

等。您需要 fflush(标准输出)因为通常标准输出缓冲,直到输出一个换行符。

etc. You need the fflush(stdout) because normally stdout is buffered until you output a newline.

这篇关于打印纺纱光标用C终端运行的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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