Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Ademan

Quick question

This topic is 5463 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Anyone know of any functions that you can use to access the computer''s clock?? thatd be cool....and also....random number generators...but...id rather not download a library since thats someone else''s work...i was hopin there was a standard library that came with microsoft visual c++ that might have it...thanx

Share this post


Link to post
Share on other sites
Advertisement
#include <mmsystem.h>

// seed the random number generator:
srand(timeGetTime());

// get a random number
int i = rand() % 10;

you have to link with winmm.lib

My Site

Share this post


Link to post
Share on other sites
hey..cool....umm...u dont mind if i use that do u??? im not just gonna rip it off...but....could i include wut u did??

Share this post


Link to post
Share on other sites
#include <mmsystem.h>
#include <iostream.h>
#include <winmm.lib>


int danrand(int smallest, int largest)

{

while (i>largest||i
{

// seed the random number generator:
srand(timeGetTime());

// get a random number
int i = rand() % 10;

}

return i;

}




and heres wut i got..figure i should give back right??? well...that is if it works anyways... thanx again

[edited by - Ademan on July 7, 2003 4:56:48 PM]

Share this post


Link to post
Share on other sites
hmmm....it seems to not like it when i do i_<_smallest....wellyah...there is is (the missing block.....but then again...im in compsc 110..so its probably wrong anyways

Share this post


Link to post
Share on other sites

int myRand(int min, int max)
{
return rand()%(max-min+1)+min
}

I think that is the function you''re looking for.


As far as I know, you only have to call srand() once (in your init). However, I have seen some weird behaviour from rand(), so I could be mistaken.



Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!