time accuracy

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mfareezaw
    New Member
    • Aug 2006
    • 2

    #1

    time accuracy

    I have this program to chk time, but the accuracy is 2 sec.
    I want more accuracy ( 1 sec or less )
    pls help , thanks

    #include <io.h>
    #include <iostream.h>
    #include <conio.h>
    #include <windows.h>

    int main(void)
    {
    FILE *stream;
    std::ftime ft;
    int h,m,s,ms;
    if ((stream = fopen("TEST.$$$ ","wt")) == NULL)
    { fprintf(stderr, "Cannot open output file.\n"); return 1; }
    getftime(fileno (stream), &ft);
    h=ft.ft_hour; m=ft.ft_min; s=ft.ft_tsec;
    printf("File time: %u:%u:%u\n",h,m ,s);
    printf("File date: %u/%u/%u\n",
    ft.ft_month, ft.ft_day,ft.ft _year+1980);
    fclose(stream);
    cout << "\n\nPress any key to continue";
    getch(); // wait for key pressure
    return 0;
    }
Working...