C言語の出力方法
#include <stdio.h>
#include <time.h>
#include <Windows.h>
int main(void)
{
time_t timer;
struct tm *t_st;
while(1){
time(&timer);
printf("現在時刻: %s\n", ctime(&timer));
sleep(1);
}
return 0;
}
と言うプログラムで、コマンドプロンプトに現在時刻を表示させています。
実行すると
C:\>zikoku
現在時刻: Tue Oct 27 23:08:19 2009
現在時刻: Tue Oct 27 23:08:20 2009
現在時刻: Tue Oct 27 23:08:21 2009
現在時刻: Tue Oct 27 23:08:22 2009
現在時刻: Tue Oct 27 23:08:23 2009
現在時刻: Tue Oct 27 23:08:24 2009
という感じでどんどん下に表示されていきますが、
C:\>zikoku
現在時刻: Tue Oct 27 23:08:19 2009
と1行だけ表示させ、この1行を毎回書き換える という事は出来ないのでしょうか?
C:\>zikoku
現在時刻: Tue Oct 27 23:08:19 2009
の1秒後
C:\>zikoku
現在時刻: Tue Oct 27 23:08:20 2009
と言う風に、下に表示ではなく、元々表示されている場所に再度と言うことです。