home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_02
/
1102127a
< prev
next >
Wrap
Text File
|
1992-12-10
|
749b
|
31 lines
// tdate2.cpp
#include <stdio.h>
#include <stdlib.h>
#include "date2.h"
main()
{
int m, d, y, nargs;
// Read in two dates - assume 1st precedes 2nd
fputs("Enter a date, MM/DD/YY> ",stderr);
nargs = scanf("%d/%d/%d%*c", &m,&d,&y);
if (nargs != 3)
return EXIT_FAILURE;
Date d1(m,d,y);
fputs("Enter a later date, MM/DD/YY> ",stderr);
nargs = scanf("%d/%d/%d%*c", &m,&d,&y);
if (nargs != 3)
return EXIT_FAILURE;
Date d2(m,d,y);
// Compute interval in years, months, and days
Date *result = d1.interval(d2);
printf("years: %d, months: %d, days: %d\n",
result->year, result->month, result->day);
return EXIT_SUCCESS;
}