Using the time in Turbo C

Discussion in 'Programmer's Corner' started by bousyass, Aug 30, 2008.

  1. bousyass

    Thread Starter New Member

    Aug 26, 2008
    Hi every one ,
    i want to know how can i use the time in turbo c .
    in my program i have to make the user write a word within 10 second .
  2. Mark44

    Well-Known Member

    Nov 26, 2007
    The first place I would start if I were you is in the time.h header, and see what functions were available, such as for getting the system time, or elapsed time. If I recall, you're using a very old version of Turbo C that none of us in this forum have.

    Take a look at what is there and report back on what you found.
  3. RiJoRI

    Well-Known Member

    Aug 15, 2007
    FWIW, I have a copy of TC 2.0, and (hidden far,far away) the TC 1.5 manuals.

    Anyway, the bolded parts may give the OP some idea:
    Code ( (Unknown Language)):
    1.   [B] time(&GUL_StartTime);[/B]                       /* Fetch present time */
    2.    [B]GUL_EndTime=GUL_StartTime + PUC_Time;[/B]           /* Add search time */
    4.         while(1){
    5.               while(!(GUC_A = lfc_sgetc()))         /* If we haven't received anything, from the SIO port */
    6.               {
    7.                if(lfc_GetOut())                   /* see if the tester has gotten impatient */
    8.                    lf_Terminate(F10_Exit);
    10.             [B]time(&GUL_PresentTime);[/B]            /* See if time's up */
    11.                 [B] if(GUL_PresentTime > GUL_EndTime)[/B]
    12.                [B]return(TIMEOUT);  [/B]              /* A-yep! */
    13.             }
    GUL_ refers to a Global Unsigned Long

    caveat user: I did this such a long time ago that I do not know if I ever used the code, which was part of a serial communications terminal program.

    Last edited: Sep 2, 2008