DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Using the internal Clock within a program.

  1. #1
    Adam Cavaney Guest

    Using the internal Clock within a program.


    Im writing a program at present, which requires me to use an internal clock.
    Basically its a video hiring shop, and i need to record the date when a video
    is hired, and then returned, and if late calculate the amount of days it
    was late. Can you please let me know how this is possible, as well as having
    a running clock on the program which displays the correct time whenever the
    program is run. Thanks for any help you can offer.

  2. #2
    David Tran Guest

    Re: Using the internal Clock within a program.


    MFC provides a CTime and CTimeSpan class, look it up with VC++. It provides
    lots of function you need.

    You can use Sleep( 1000 ), 1000 mean 1 second of delay.

    OR

    You can simply make loops like so to simulate a clock..
    e.g.

    // This is not really a good way to do it...Using Sleep( N ) is better.
    // You can use this type of format to simulate a second.
    for ( i=0; i<N; i++ ) {
    for ( j=0; j<N; j++ ) {
    i++;
    .... // You code that require time for their calculation here
    }
    j++;
    }

    If you are not using MFC, try time.h,

    Hope this help.

    David

    "Adam Cavaney" <acavaney@hotmail.com> wrote:
    >
    >Im writing a program at present, which requires me to use an internal clock.
    >Basically its a video hiring shop, and i need to record the date when a

    video
    >is hired, and then returned, and if late calculate the amount of days it
    >was late. Can you please let me know how this is possible, as well as having
    >a running clock on the program which displays the correct time whenever

    the
    >program is run. Thanks for any help you can offer.



  3. #3
    Danny Kalev Guest

    Re: Using the internal Clock within a program.

    this month's 10 minute solution may be of interest to you:
    http://gethelp.devx.com/techtips/cpp.../10min1200.asp

    Danny

    Adam Cavaney wrote:
    >
    > Im writing a program at present, which requires me to use an internal clock.
    > Basically its a video hiring shop, and i need to record the date when a video
    > is hired, and then returned, and if late calculate the amount of days it
    > was late. Can you please let me know how this is possible, as well as having
    > a running clock on the program which displays the correct time whenever the
    > program is run. Thanks for any help you can offer.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center