no he usado mucho la libreria time.h pero tengo esto:
typedef struct
{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
}tm;
No lo uses, en su lugar incluyes <time.h> y utilizas el tipo "struct tm". El porque se indica en la referencia:
struct tm contains members that describe various properties of the calendar time. The members shown above can occur in any order, interspersed with additional members.
y luego que?
Llamas a la funcion mktime e imprimes el valor del campo "tm_yday". Por ejemplo:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main(void)
{
struct tm d = {0};
puts("Introduce la fecha (aaaa mm dd):"); if (scanf("%d %d %d", &d.
tm_year, &d.
tm_mon, &d.
tm_mday) != 3) return EXIT_FAILURE;
d.tm_year -= 1900; /* 0 == 1900, 100 == 2000, etc. */
d.tm_mon--; /* 0 == Enero, 1 == Febrero, etc. */
if (mktime(&d
) == (time_t
) -1){ return EXIT_FAILURE;
}
printf("%4d/%02d/%02d ==> Dias transcurridos: %d\n", d.tm_year + 1900, d.tm_mon + 1, d.tm_mday, d.tm_yday);
return EXIT_SUCCESS;
}
Un saludo