Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>difftime() find the difference between two times</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 difftime()              Find the Difference between Two Times

 #include <time.h>

 double     difftime(time2,time1);
 time_t     time2;                       Type 'time_t' defined in <time.h>
 time_t     time1;                       Type 'time_t' defined in <time.h>


    Difftime() calculates the difference, in seconds, between 'time2' and
    'time1'.

    Returns:    A double-precision number representing 'time2' - 'time1'.

   ----------------------------- Example ------------------------------

    The following statements open a file, set the start time, process the
    file, set the end time, then find out how much time it took to
    process the file.

            #include <time.h>
            #include <stdio.h>

            time_t   time1, time2;
            FILE     *in;
            int      x;

            main()
            {
                if ((in = fopen("acct.dat","w+")) != NULL) {
                     time(&time1);
                     for (x = 1; x < 15000; x++)
                         fputc(x,in);
                     rewind(in);
                     while (!feof(in)) {
                         fgetc(in);
                     }
                     time(&time2);
                     printf("Time it took to process the file: %f\n",
                             difftime(time2,time1)
                }
            }


See Also: time()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson