C言語 \b \r
・\b
表示位置が、その行内での直前の位置に移動する。
・\r
現在位置が、その行の先頭に移動する
/*--- xミリ秒経過するのを待つ ----*/
int Sleep(unsigned long x)
{
clock_t c1 = clock(), c2;
do {
if*1 == (clock_t)-1) /* エラー */
return(0);
} while(1000.0 * (c2 - c1) / CLOCKS_PER_SEC < x);
return(1);
}
int main(void)
{
int i;
printf("ABCDEFG");
for(i = 0; i < 7; i++) {
Sleep(1000); /*後ろから1文字ずつ*/
printf("\b\b"); /* 1秒ごとに消す */
fflush(stdout); /* バッファを掃き出す */
}
return(0);
}
*1:c2 = clock(