代码如下:
#include <stdio.h>
#include <Windows.h>int main() {int total = 100;int progress = 0;char progressBar[101] = {};while (progress <= total) {progressBar[progress] = '#';printf("[%-100s] %d%%", progressBar, progress);fflush(stdout);Sleep(100);printf("\r");progress++;}printf("\n");return 0;
}
效果如下: