C嵌如式开发有求2个日期相差天数的函数吗?该如何处理

C嵌如式开发有求2个日期相差天数的函数吗?
如题

------解决方案--------------------
1 #include <stdio.h>
2 #include <time.h>
3
4 int rDiff(struct tm *to, struct tm *from)
5 {
6 from-> tm_year -= 1900;
7 from-> tm_mon--;
8 from-> tm_hour = 0;
9 from-> tm_min= 0;
10 from-> tm_sec = 0;
11 from-> tm_isdst = -1;
12 to-> tm_year -= 1900;
13 to-> tm_mon--;
14 to-> tm_hour = 0;
15 to-> tm_min = 0;
16 to-> tm_sec = 0;
17 to-> tm_isdst = -1;
18 time_t _from = mktime(from);
19 time_t _to = mktime(to);
20
21 return (int)difftime(_from,_to)/86400;
22 }

25 int main()
26 {
27 struct tm _from;
28 _from.tm_year = 2007;
29 _from.tm_mon = 7;
30 _from.tm_mday = 3;
31 struct tm _to;
32 _to.tm_year = 2007;
33 _to.tm_mon = 7;
34 _to.tm_mday = 8;
35 printf( "%d\n ",rDiff(&_from,&_to));
return 0;
36 }
------解决方案--------------------
typedef struct
{
int y;
int m;
int d;
}date_t;

int minusDay(date_t *to,date_t *from)
{
...
}