Milliseconds?

This is a discussion on Milliseconds? within the C++ Programming forums, part of the General Programming Boards category; Hi. in many languages, there is a functions that will return an integer representing the number of milliseconds that the ...

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    7

    Milliseconds?

    Hi. in many languages, there is a functions that will return an integer representing the number of milliseconds that the PC has been on. I am having trouble finding a similar function in c++. I've searched Google and could not find what I was looking for.

    Any help would be greatly appreciated.

  2. #2
    Registered User
    Join Date
    Dec 2007
    Posts
    812
    GetTickCount.
    Compiler MSVC++ 2013 with Code::Blocks.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,767
    > I am having trouble finding a similar function in c++
    Well there isn't one in standard C++.

    Which means that if Ducky's guess that you're using windows is wrong, then you need to tell us which OS/Compiler you are using.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Aug 2010
    Posts
    7
    I'm using windows with code::blocks and mingw, but i am writing a multi-platform app.

  5. #5
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Posts
    22,920
    There is no multi-platform function. You're going to have to wrap your function calls to your own function, say, GetMilliSecSinceBoot. Then put a couple of typedefs there to call and appropriate function for any given platform. GetTickCount is for Windows.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Time in milliseconds
    By coder_009 in forum C Programming
    Replies: 4
    Last Post: 05-09-2008, 04:36 AM
  2. text comparing
    By Picachu in forum C Programming
    Replies: 48
    Last Post: 12-14-2006, 03:44 AM
  3. Current System Time (In Milliseconds)
    By IGAU in forum C Programming
    Replies: 10
    Last Post: 03-30-2004, 06:53 PM
  4. Time in milliseconds?
    By d00b in forum C++ Programming
    Replies: 3
    Last Post: 08-05-2002, 10:33 PM
  5. Milliseconds
    By Magos in forum C++ Programming
    Replies: 8
    Last Post: 11-01-2001, 03:13 PM

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