Desc :
Source Code :
#include <stdio.h>
#include <time.h>
#define DAYSEC (24*60*60)
void main()
{
time_t now;
struct tm t, chrismas = {0,0,0,25,12,2021};
int n1, n2, nChrismas;
now = time(NULL);
t = *localtime(&now);;
chrismas.tm_year -= 1900;
chrismas.tm_mon -= 1;
t.tm_hour = 0;
t.tm_min = 0;
t.tm_sec = 0;
n1 = mktime(&t);
n2 = mktime(&chrismas);
nChrismas = (n2 - n1);
chrismas = *localtime(&nChrismas);
printf("크리스마스까지 %d개월 %d일 남았습니다! \n"
, chrismas.tm_mon , chrismas.tm_mday);
}
Result :
'C' 카테고리의 다른 글
[C] 250 크리스마스의 요일 구하기 mktime, strftime (0) | 2021.02.08 |
---|---|
[C] 249 오늘 날짜에 임의의 날짜 더하고 빼기 mktime (0) | 2021.02.08 |
[C] 247 D-DAY 구하기 mktime (1) | 2021.02.08 |
[C] 246 각 달의 마지막 날짜 구하기 mktime() (1) | 2021.02.08 |
[C] 245 특정일로부터 경과일 수 구하기 mktime (1) | 2021.02.08 |