Newbe C code (windows) question can't get system time.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • hnash
    New Member
    • Jan 2008
    • 2

    Newbe C code (windows) question can't get system time.

    I am learning C, I am working in windows not unix. I need
    a way to get the time, write to a variable "time1" then execute
    a section of code. When the section is finished I need to
    get the time and write to time2. I can later measure execution
    time. In windows time.h more time_t and clock_t are
    computations and they don't gime me time. Any pointers?
  • jaarmstr
    New Member
    • Jan 2008
    • 5

    #2
    if all you want to do is measure time taken then do this.

    #include <time.h>
    #include <stdlib.h>/*this is for the NULL (i hope)*/

    double start,end;

    start=time(NULL );
    /*your code to be timed goes here*/
    end =time(NULL);
    printf("time taken is %f",end-start);

    i hope this is what you mean!

    Comment

    • hnash
      New Member
      • Jan 2008
      • 2

      #3
      Well that looks simple, I shal try that tomorrow.

      Thanks!

      Comment

      • qweasdzxciopjklbnm
        New Member
        • Jul 2008
        • 1

        #4
        I recently wrote a c++ header file called EZTime and it contains 10 functions for writing time and date, and many individual variables, such as hour, minute, militaryhour, and such. The current version does not have a ticking clock function, but the next version, due out 7/19/2008 will. All future and current EZTime header files can be downloaded here : http://xxxxxxxx.xxx

        moderator note: that link stinks; I removed it.
        Last edited by RedSon; Jul 14 '08, 03:30 PM. Reason: Actually you didn't remove it...but I did.

        Comment

        Working...