VC6控制台模式下的进度条问题
1.在Linux系统安装rpm程式时,常会在中看到安装进度条,不知道那是怎做的,这功能怎在VC6中实现?#####################100%
2.VC6中printf();是在DOS视窗中显示字符串,但是如何才能同一行显示字符串不停变换而不换行?
是要用其他函式来做吗?求提示~
程序代码:#include <windows.h>
#include <time.h>
#include <stdio.h>
void printtime( const struct tm* ptm )
{
printf( "%04d年%02d月%02d日 %02d时%02d分%02d秒\n"
, ptm->tm_year+1900, ptm->tm_mon+1, ptm->tm_mday
, ptm->tm_hour, ptm->tm_min, ptm->tm_sec );
printf( "本年第%03d天,星期%01d\n"
, ptm->tm_yday+1, ptm->tm_wday );
}
int main( void )
{
HANDLE hOutput = ::GetStdHandle(STD_OUTPUT_HANDLE);
printf( "%s", "当前时间: " );
CONSOLE_SCREEN_BUFFER_INFO screen_info;
::GetConsoleScreenBufferInfo( hOutput, &screen_info );
for( time_t t1=0,t2; t2=time(0); Sleep(100) )
{
if(t2==t1) continue;
t1 = t2;
struct tm* tmo = localtime( &t1 );
::SetConsoleCursorPosition(hOutput,screen_info.dwCursorPosition);
printtime( tmo );
}
return 0;
}