C语言动态进度条

#include <iostream>
#include <windows.h>

void HideCursor()
{
CONSOLE_CURSOR_INFO cursor_info = {1, 0};
SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursor_info);
}

void Gotoxy(int x,int y)
{
HANDLE hout;
COORD coord;
coord.X=x;
coord.Y=y;
hout=::GetStdHandle(STD_OUTPUT_HANDLE);
::SetConsoleCursorPosition(hout,coord);
}

void DrawBox()
{
printf("╔═════════════════════════╗");
putchar('\n');
printf("║ ║");
putchar('\n');
printf("╚═════════════════════════╝");

}

int main()
{
HideCursor();
DrawBox();
for(int len=1;len<=25;len++)
{
Gotoxy(2*len,1);
printf("█");
Gotoxy(21,4);
printf("%d%%",4*len);
Sleep(100);

}


return 0;
}

猜你喜欢

转载自www.cnblogs.com/LyShark/p/9051739.html