Salve a tutti, vorrei una piccola mano con del codice in ANSI C.
Praticamente dovrei creare un cronometro che una volta fermato, dopo averlo avviato, mi restituisca il tempo e me lo salvi in un file.
codice:
void stopwatch(){    time_t start_time;
    time_t stop_time;
    int hour,h = 0;
    int sec;
    int min,m = 0;
    int s=0;
    int n=0;
    int c;
    CLEAR();
    int id=0;
    char weather[15];
    FILE *fp;
    fp=fopen(file3,"a");
    printf("Write Pilot ID: ");
    scanf("%d", &id);
    printf("\nInsert weather conditions: ");
    scanf("%s",weather);
    CLEAR();
    printf("\tPress any number to START stopwatch\n");
    scanf("%d",&n);


    while(( c = getchar() ) != '\n' && c != EOF );
    start_time = time(NULL);


    do{
        printf("\tPress the Enter Key to Stop the stopwatch");
    }while(( c = getchar() ) != '\n' && c != EOF );
    stop_time = time(NULL);


    sec = difftime( stop_time , start_time );


    while( sec >= 60 ){
        min++;
        sec = sec - 60;
    }
    while( min >= 60){
        hour++;
        min = min -60;
    }
            CLEAR();




    fprintf(fp,"%d\t%s\t%02d:%02d:%02d\n",id,weather,hour,min,sec);
    printf("Pilot ID: %d\n",id);
    printf("Weather: %s\n",weather);
    printf("Time: %02d:%02d:%02d\n",hour,min,sec);


fclose(fp);


}
Questo è il codice, ma non mi visualizza il cronometro in tempo reale. Ho provato ad aggiungerlo, ma non saprei come bloccarlo senza utilizzare librerie non standard.
Qualcuno potrebbe aiutarmi?