time help plz ppl

This is a discussion on time help plz ppl within the C++ Programming forums, part of the General Programming Boards category; i need to get the milli second off the clock on the computer... now how would i go about getting ...

  1. #1
    Registered User
    Join Date
    Jan 2004
    Posts
    12

    time help plz ppl

    i need to get the milli second off the clock on the computer... now how would i go about getting that? plz can any one help?
    if u c this i will be asking for help

  2. #2
    Registered User
    Join Date
    Jan 2003
    Posts
    648
    Code:
    #include <ctime>
    clock_t std::clock();
    It returns the CPU time since the program started. The constant CLOCKS_PER_SECOND can convert the return value into seconds. Example:
    Code:
    #include <ctime>
    #include <iostream>
    using namespace std;
    
    int main() {
       // do something CPU intensive here...
    
       double seconds = clock() / double(CLOCKS_PER_SECOND);
       cout << "This program has been running for " << seconds << " seconds." << endl;
       return 0;
    }
    Last edited by Speedy5; 04-25-2004 at 11:01 AM.

  3. #3
    Registered User
    Join Date
    Jan 2004
    Posts
    12
    error C2065: 'CLOCKS_PER_SECOND' : undeclared identifier
    if u c this i will be asking for help

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,303
    Could try:
    CLK_TCK
    or
    CLOCKS_PER_SEC
    instead

    what compiler/IDE are you using?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Jan 2004
    Posts
    12
    Microsoft Visual C++ 6.0
    if u c this i will be asking for help

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Determine the closest departure time
    By Kyeong in forum C Programming
    Replies: 9
    Last Post: 10-07-2008, 09:06 PM
  2. Execution Time - Rijandael encryption
    By gamer4life687 in forum C++ Programming
    Replies: 5
    Last Post: 09-20-2008, 10:25 PM
  3. Journey time prog 1 minute wrong
    By mike_g in forum C Programming
    Replies: 4
    Last Post: 10-12-2006, 04:41 AM
  4. calculating user time and time elapsed
    By Neildadon in forum C++ Programming
    Replies: 0
    Last Post: 02-10-2003, 06:00 PM

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