반응형

// 날짜및 시간 구하기 1(localtime)

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

 

void main(void)
{
 time_t now;
 struct tm t;

 time(&now);

 t = *localtime(&now);

 printf("현재 날짜 및 시간:%4d.%d.%d %d:%d:%d\n", t.tm_year+1900, t.tm_mon+1, t.tm_mday
  ,t.tm_hour,t.tm_min, t.tm_sec);
}

// 날짜 및 시간 구하기 2(_ftime)

#include <stdio.h>
#include <time.h>
#include <sys/timeb.h>

 

void main(void)
{
 struct _timeb tb;
 struct tm t;

 _ftime(&tb);

 t=*localtime(&tb.time);

 printf("현재 날짜 및 시간 : %4d.%d.%d %d:%d:%d.%d \n"
  , t.tm_year+1900, t.tm_mon+1, t.tm_mday
  , t.tm_hour, t.tm_min, t.tm_sec, tb.millitm);
}

 

반응형

'프로그래밍 > C 언어' 카테고리의 다른 글

c++ 에서 new, delete 메모리 할당 해제 관련글  (0) 2009.05.07
memset 사용법 - 주의사항  (1) 2009.02.11
debuging 하기. (아파치에서)  (0) 2009.02.11
c언어 함수 요약  (0) 2009.02.11

+ Recent posts