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