void fun()
{
int i = 0;
char bar[102] = { 0 };
printf("数据输入中,请稍后\n");
while (i <= 50)
{
printf("[%-50s][%3d%%]\r", bar, i * 2);
Sleep(60);
bar[i++] = '*';
bar[i] = '\0';
}![在这里插入图片描述](https://img-blog.csdnimg.cn/20191126171252555.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQ0NzU1NDAz,size_16,color_FFFFFF,t_70)
printf("\n数据输入完毕\n");
}
[%-50s]
意思是输出一个 [“50个空格”],
[%3d%%]
意思是输出:[100%]
改变printf输出字体颜色:
#include<Windows.h>
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), x);
x是一个数值,改变颜色