i want to make a clock

This is a discussion on i want to make a clock within the C++ Programming forums, part of the General Programming Boards category; any sugestion were to start?...

  1. #1
    Unregistered
    Guest

    i want to make a clock

    any sugestion were to start?

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Consider how you're going to get the time from the system, and consider how you're going to put graphics on the screen.

  3. #3
    Unregistered
    Guest
    can u help me with a graphic clock?

  4. #4
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    We all can try...

    Do you know any C++, first of all... This isn't something you can just jump into saying "I want to make a clock" and get one that evening.

  5. #5
    Unregistered
    Guest
    yes i'm a member to actually but i forgot to register
    my nickname's pode
    well i guess i can program .not so much object oriented though
    and no graphics

  6. #6
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    hi

  7. #7
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    In that case - haven't you asked this before (several times)?

    You're not still trying to make a clock that doesn't rely on system time, are you?

  8. #8
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    ok ok
    i'll do it your way

  9. #9
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    yay i'm a menber( )
    but how?!

  10. #10
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    > but how?!

    You made 30 posts...

  11. #11
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    look at u 7 more to the next millenium

    what's next, senior member?

  12. #12
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    Last time, if I remeber correctly you refused to give information regarding your compiler. If I was going to write a rough clock using a Windows based compiler I'd do something like -

    Code:
    #include <iostream>
    #include <iomanip>
    #include <windows.h>
    using namespace std;
    
    void gotoxy(int x,int y)
    {
        HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        COORD c = {x,y};
        SetConsoleCursorPosition(hConsole,c);
    }
    
    
    
    int main()
    {
        int hours,minutes,seconds;
        cout << "Initialise Clock\n";
        cout << "hours: ";
        cin >> hours;
        cout << "minutes: ";
        cin >> minutes;
        cout << "seconds: ";
        cin >> seconds;
    
        while(1)
        {
            if(seconds==60)
            {
                seconds=0;
                minutes++;
            }
    
            if(minutes==60)
            {
                minutes=0;
                hours++;
            }
    
            if(hours==24)
                hours=0;
    
    
            cout << setfill('0')  <<  setw(2) << hours << ':' << setw(2) <<
                minutes << ':' << setw(2) << seconds++;
    
            Sleep(1000);
            gotoxy(0,4);
        }
    
        return 0;
           
        
    }
    Perhaps you can convert that to whatever compiler/os you're using.

  13. #13
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    hey that was fast
    some questions:
    what does the goto x,y do?
    iss it nesesary?
    and setfill('0')?

  14. #14
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    >what does the goto x,y do?

    Moves the current cursor position to a location on the console screen

    >iss it nesesary?

    If you want to have the clock remain in the same place then it's one solution. Alternatively you could clear the screen each loop, or backspace to required number of characters (hackish and looks crap).

    >and setfill('0')?

    Sets the fill character to '0' so that a zero is displayed if the hours/minutes/seconds is below 10. With -

    01:01:01

    without -

    1: 1: 1

  15. #15
    Registered User
    Join Date
    Dec 2001
    Posts
    479
    can u tell me what this does

    HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    COORD c = {x,y};
    SetConsoleCursorPosition(hConsole,c);
    }

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. trying to make a KenGen ( for a game tool )
    By lonewolfy in forum C# Programming
    Replies: 4
    Last Post: 03-28-2007, 08:23 AM
  2. Win32 Common Controls in C++, how do i make and use them?
    By C+noob in forum Windows Programming
    Replies: 6
    Last Post: 01-09-2006, 10:53 AM
  3. make all rule
    By duffy in forum C Programming
    Replies: 9
    Last Post: 09-11-2003, 01:05 PM
  4. Question about atheists
    By gcn_zelda in forum A Brief History of Cprogramming.com
    Replies: 160
    Last Post: 08-11-2003, 11:50 AM
  5. 'functions' in make?
    By mart_man00 in forum C Programming
    Replies: 1
    Last Post: 06-21-2003, 02:16 PM

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