0

how to compare dates in c++

21st Mar 2018, 5:09 PM
Ann
Ann - avatar
4 ответов
+ 8
use like this: #include<stdio.h> #include<conio.h> struct date { int day; int month; int year; }; void main() { struct date d1,d2; clrscr(); printf(“Enter first date(dd/mm/yyyy):”); scanf(“%d%d%d”,&d1.day,&d1.month,&d1.year); printf(“nEnter second date(dd/mm/yyyy):”); scanf(“%d%d%d”,&d2.day,&d2.month,&d2.year); if((d1.day==d2.day)&&(d1.month==d2.month)&&(d1.year==d2.year)) printf(“nEQUAL”); else printf(“nUNEQUAL”); getch(); }
21st Mar 2018, 5:21 PM
Baraa AB
Baraa AB - avatar
+ 1
if you have dates in the form of dd:mm:yy. first compare year, if years are same, then compare months and at last day.
21st Mar 2018, 5:20 PM
Vijay
Vijay - avatar
+ 1
You need to compare a recorded date to the current date? Is this what you are asking?
21st Mar 2018, 8:01 PM
Zeke Williams
Zeke Williams - avatar
0
I need to get the difference in the amount of 10 months. how to do it?
21st Mar 2018, 5:22 PM
Ann
Ann - avatar