clock simulation in C++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rheij
    New Member
    • Mar 2006
    • 2

    #1

    clock simulation in C++

    Im having a problem in creating a program which simulate clock in c++, where you will input a number in terms of minutes and convert it into hours and the converted hours will be the basis for the simulation. where the output is a clock counting until it reach the number of hours converted. hope someone will help me...

    Thank in advance....

    Yours truly,

    rheij
  • olandere
    New Member
    • Mar 2006
    • 2

    #2
    Sounds like you need to learn the modulo operator '%' in c++. Also see http://en.wikipedia.org/wiki/Modular_arithmetic

    Comment

    • Banfa
      Recognized Expert Expert
      • Feb 2006
      • 9067

      #3
      Which bit of the problem is causing you the problem?

      Post your attempt at a solution and we will help you make it work.

      Comment

      • sanou
        New Member
        • Jul 2006
        • 19

        #4
        Well I'm working on a clock too.

        Working with time.h here is some pseudocode

        global variables: flag = 0, start_time = 0, end_time = 0

        button_click_fu nction()
        if flag = 0
        start_time = clock()
        flag = 1
        else
        end_time = clock()
        flag = 0


        so this works fine. clicking on a button captures an initial time point, click on the button again grabs an end point. i can subtract the two time values to see how much time is elapsed

        my end goal is to simulate a digital clock. i'm not sure if i'm on the right track here. my next step has been working on udpating a textfield with the current time.

        my pseudo code is

        while(flag != 0) //while timer is still going
        textfield = elapsed time //clock() - start_time

        judging from the fact that my prog is now crashing, i know i'm doing something fundamentally wrong, but i can't figure out what.

        any ideas?

        Comment

        Working...