컴퓨터 시간을 읽어보아요
#include “stdio.h”
#include “time.h”
struct tm *newtime;
time_t aclock;
int main( void )
{
// 시간값 읽기(초단위로 저장)
time( &aclock );
// tm 구조체로 변환
newtime = localtime( &aclock );
// 문자열 형태로 출력
printf( “Current date and time: %s”, asctime( newtime ) );
// 각 값으로 출력
printf(“current time is: %2d: %02d:%02d
“, newtime->tm_hour, newtime->tm_min, newtime->tm_sec);
}
\