c語言實現清屏以及顯示當前日期

Move to Position         ESC[row;colH         Move the cursor to the (col, row) position. Note that the row comes before column; that is, y comes before x. Either col or row can be omitted. Row and column both start with "1," not zero. (1, 1) corresponds to the top-left corner of the screen.

Clear Screen         ESC[2J         Clear the whole screen and position the cursor to the top left corner.


"/033[1H/033[2J"相當於ESC[1H  ESC[2J,就是說把光標移到左上角,然後清屏

 

 

#include <time.h>
#include <stdio.h>

int main(void)
{
   time_t timer;
   struct tm *tblock;

   /* gets time of day */
   timer = time(NULL);

   /* converts date/time to a structure */
   tblock = localtime(&timer);

   printf("Local time is: %s", asctime(tblock));

   return 0;
}
 
 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章