Archived

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

Ademan

Quick question

Recommended Posts

Ademan    100
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
Ademan    100
#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
Ademan    100
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
gilmenel    122

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