V2.00.000:
root@u12d32:/home/kongjun/work/hi_test/time_count_down# cat time_test.c
#include
#include
#include
int main()
{
#if 1
int bootdelay = 10;
printf("Hit any key to stop autoboot: %2ds ", bootdelay);
fflush(stdout);
while(bootdelay > 0)
{
sleep(1);
--bootdelay;
printf("\b\b\b\b%2ds ", bootdelay);
fflush(stdout);
}
#endif
printf("\n");
int i;
printf(".................\n");
for(i = 5; i > 0; i--)
{
if(i == 5)
{
printf("Wait %ds",i);
fflush(stdout);
sleep(1);
}
else
{
printf("\b\b%ds",i);
fflush(stdout);
sleep(1);
}
}
printf("\n");
return 0;
}
运行效果图:
V1.00.001:
#include
#include
#include
int main()
{
#if 1
int bootdelay = 10;
printf("Hit any key to stop autoboot: %2d ", bootdelay);
fflush(stdout);
while(bootdelay > 0)
{
sleep(1);
--bootdelay;
printf("\b\b\b%2d ", bootdelay);
fflush(stdout);
}
#endif
int i;
printf(".................\n");
for(i = 5; i > 0; i--)
{
if(i == 5)
{
printf("Wait %d",i);
fflush(stdout);
sleep(1);
}
else
{
printf("\b%d",i);
fflush(stdout);
sleep(1);
}
}
return 0;
}
运行效果图: