Tick Please

This is a discussion on Tick Please within the C++ Programming forums, part of the General Programming Boards category; Hi All, Please help my little prog to display date and time, but I want the time to display with ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    8

    Question Tick Please

    Hi All,

    Please help my little prog to display date and time, but I want the time to display with ticking second and it's not doing that :-( why?

    Thanks for any help. Borland C++ 3.0 compiler.

    Code:
    #include <stdio.h>
    #include <conio.h>
    #include <time.h>
    #include <dos.h>
    
    int main()
    {
        struct date d;
        getdate(&d);
        struct  time t;
        gettime(&t);
    
        clrscr();
        textcolor(14);
        gotoxy(60,3);
        printf("Date: %d/%d/%d",d.da_day,d.da_mon,d.da_year);
        while (!kbhit())
        {
    	gotoxy(60,4);
    	printf("Time: %2d:%02d:%02d",t.ti_hour, t.ti_min, t.ti_sec);
        }
        return 0;
    }

  2. #2
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    put 'getdate( &d )' and gettime( &t )' in the loop
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  3. #3
    Spanky devour89's Avatar
    Join Date
    Nov 2002
    Posts
    148
    Try this...

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <time.h>
    #include <iostream.h>
    #include <conio.c>
    
    int main()
    {
    
    for (int x=0;x>=0;x++)
    {
      time_t now;
      time(&now);
      
      printf("%s", ctime(&now));
      Sleep(100);
      clrscr();
      
    }
    return main();
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with Sleep and GetTickCount().
    By IamBMF in forum C Programming
    Replies: 13
    Last Post: 02-03-2008, 08:25 AM
  2. How to put a tick in a windows menu?
    By cloudy in forum Windows Programming
    Replies: 1
    Last Post: 07-08-2007, 05:02 PM
  3. client server tick tack toe
    By a02227 in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 11-20-2004, 02:58 PM
  4. timer tick algorithms
    By Mohsinzb in forum C Programming
    Replies: 1
    Last Post: 03-27-2002, 11:58 AM
  5. resize problems
    By Isometric in forum Windows Programming
    Replies: 11
    Last Post: 11-22-2001, 01:32 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21