Posts: 357
Threads: 118
Joined: Oct 2004
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.
Posts: 357
Threads: 118
Joined: Oct 2004
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.
Posts: 677
Threads: 57
Joined: Jan 2005
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/]
[/url]
Posts: 357
Threads: 118
Joined: Oct 2004
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.
Posts: 838
Threads: 17
Joined: Jan 2002
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
Posts: 357
Threads: 118
Joined: Oct 2004
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.
Posts: 677
Threads: 57
Joined: Jan 2005
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/]
[/url]
Posts: 357
Threads: 118
Joined: Oct 2004
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.
Posts: 495
Threads: 29
Joined: Sep 2005
What OS you're using should be irrelavent if you're using standardized header files, which are availble through every C++ compiler.
Posts: 677
Threads: 57
Joined: Jan 2005
Quote:OSX is Mac.
...0_0 you learn a new, useless fact everyday...
ctime sould work fine...and I've heard of clock(), what does that do?
url=http://www.sloganizer.net/en/]
[/url]