[c언어] 현재 시간을 연속적으로 출력(kbhit, localtime)

|



 현재 시간을 연속적으로 출력(kbhit, localtime)
kbhit() 은 입력된 키가 있으면 0이 아닌 값을, 입력된 키가 없으면 0을 반환

#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include <conio.h>
int main(void)
{
    time_t now;
    struct tm *d;
    while(!kbhit())
    {
        system("cls");
        now=time(NULL);
        d=localtime(&now);
        printf("현재 날짜와 시간 : %s\n", asctime(d));
    }
    return 0;
}

// 실행 결과



  ::