생년월일을 입력하면 만 나이를 계산하는 프로그램, 현재 날짜를 기준으로 하고 함수 localtime()이용
sin
생년월일을 입력하면 만 나이를 계산하는 프로그램, 현재 날짜를 기준으로 하고 함수 localtime()이용만 나이 = (현재 년도 - 생년) - (생일이 지났으면 0, 생일이 지나지 않았으면 1)질문 내용 :프로그램 에러가 자꾸 나요... ㅠ.ㅠ
생년 월일 입력하면 프로그램 디버그 에러가 납니다.
#include time.h
#include stdio.h
#include windows.h
int main(void)
{
int birthy, birthm, birthd;
time_t curr;
struct tm *d;
curr=time(null);
d=localtime(&curr);
printf(생년을 입력하고 enter하시오.);
scanf(%d, birthy);
printf(생월을 입력하고 enter하시오.);
scanf(%d, birthm);
printf(생일을 입력하고 enter하시오.);
scanf(%d, birthd);
printf(현재날짜\n);
printf(%d년%d월%d일\n, d-tm_year+1900,d-tm_mon+1,d-tm_mday);
printf(입력된 날짜\n);
printf(%d년%d월,%d일\n,birthy,birthm,birthd);
diffy=birthy - d- tm_year+1900;
diffm=birthm - d- tm_mon+1;
diffd=birthd - d- tm_mday;
if (diffm=0 && diffd=0)
diffy++;
printf(만나이 : %d\n, diffy);
return 0;
}