Ciao a tutti, devo scrivere un programma che, inserite due date, mi restituisca la differenza in giorni. Devo, inoltre, inserire le due date nel file "input.txt" e il risultato nel file "output.txt".
Non so come scrivere l'fprintf del file "input.txt", potreste darmi una mano?
Il codice è il seguente.

codice:
#include <stdio.h>
#include <time.h>
int main ()
{
    static struct tm date1;
    static struct tm date2;
    time_t start, end, startdate, enddate;
    double diffsec;
    int d, m, y;
    FILE *in, *out;
    system ("color 1b");
    time (&start);


    in = fopen ("input.txt", "w");
    out = fopen ("output.txt", "w");


    do
    {
        printf ("Enter the start-date using the slash bar (/): ");
        scanf ("%d/%d/%d", &d, &m, &y);
        date1.tm_mday = d;
        date1.tm_mon = m-1;
        date1.tm_year = y - 1900;


        printf ("Enter the end-date using the slash bar (/): ");
        scanf ("%d/%d/%d", &d, &m, &y);
        date2.tm_mday = d;
        date2.tm_mon = m-1;
        date2.tm_year = y - 1900;
    }
    while (mktime(&date2) < mktime(&date1) || d>31 || m>12 || y<1900 || d==0 || m==0);


    fprintf (in, "", ); //COSA DEVO SCRIVERE?
    fprintf(out, "%.f", difftime(mktime(&date2), mktime(&date1))/86400);
    fclose (in);
    fclose (out);
    time (&end);
    diffsec = difftime (end, start);


    printf ("\n");
    if (difftime(mktime(&date2), mktime(&date1))/86400 == 1)
        printf ("The difference between the dates is 1 day\n");
    else
        printf ("The difference between the dates is %.f days\n", difftime(mktime(&date2), mktime(&date1))/86400);
    printf ("\n");
    printf ("Time of execution: %f seconds\n", diffsec);
    printf ("\n");
    system ("PAUSE");
}