Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Really nood question
#1
How do I get the time in milliseconds (or something close) in C++. I'm using a time_t data type and setting it to time(NULL). Then when I cout it I typcast it as a double, but it always prints out an integer. Of course I've got the #include <ctime> declaration at the top.

I have to be able to do this without Windows librarys (I'm on OSX) and without intel chipset commands (Its got a Motorola chipset.)
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply
#2
Okaaaay. I guess it wasn't such a noob question. Okay, how do you do it on a PC? XCode has most common C++ PC functions included in libraries.
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply
#3
without windows, dunno, i try not to picture my life without it.

So many games unplayed
So many downloads usable
So many optimizers for morrowind untouchable...

Me: Windows XP Or 2000?
Other Dude: Linux....
me: Get Running.

i know windows does timeGetTime(), maybe #include <ctime> has the answer. I'm gonna have to look into this
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#4
Who said anything about Linux? OSX isn't Linux. Looking at my picture and my signature that should be obvious. Secondly, OSX is perfectly happy running Virtual PC and anything you can download and run I can download and run too (except for virii and spyware. :-P)

Anyway it couldn't find timeGetTime(), I assume I need to include something, what header is it?
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply
#5
timeGetTime is declared in mmsystem.h, but afaik that's a windows only thing. I could very possibly be wrong though.

Try GetTimeOfDay from time.h, it returns seconds and milliseconds.

Code:
#include <sys/time.h>

int gettimeofday(struct timeval * tv , struct timezone * tz );

And the timeval struct contains tv_sec and tv_usec, seconds and microseconds. For timezone just pass NULL, it's supposed to return the timezone, but it's obsolete on many systems.
url=http://www.copy-pasta.com]CopyPasta[/url] - FilePasta
Reply
#6
Thanks Zap, worked great.
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply
#7
Quote:Who said anything about Linux? OSX isn't Linux.

I just said Linux because it popped into my head. In all honesty i've never heard of OSX, onlky Windows, Mac and Linux.
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply
#8
OSX is Mac.

<- 1984 Mac commercial

Apple's motto
|
v
f you play a Microsoft CD backwards you can hear demonic voices. The scary part is that if you play it forwards it installs Windows.
Reply
#9
What OS you're using should be irrelavent if you're using standardized header files, which are availble through every C++ compiler.
[Image: 1403.png]
^ Infrosoft
http://www.thecodeyouneed.us.to/ - A wiki of source code, mostly in PHP and FreeBASIC
http://www.osadvocacy.uk.to/ - Your opinion matters no matter your OS
Reply
#10
Quote:OSX is Mac.

...0_0 you learn a new, useless fact everyday...

[Image: 20040703.jpg]

ctime sould work fine...and I've heard of clock(), what does that do?
url=http://www.sloganizer.net/en/][Image: style4,TheDarkJay.png][/url]
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)