Can someone point me to one, because our high-school library is way too old. And it wont work with Dev-C++(we using in it in CS class). Thank you.

/*	Lawrenceville Press Random Library                */
/*	October 1997                                      */
/*	The following code works correctly under BOTH     */
/*	Borland and MSC. The library is only compiled if  */
/*	running under MSC                                 */

#include <iostream.h>
#include <stdlib.h>

//--------RANDOM LIBRARY--------------
//------------------------------------
#if defined(_MSC_VER)
#include <stdlib.h>
#include <time.h>
void randomize()
{
	 time_t t;
	 srand((unsigned) time(&t));
}
//------------------------------------
int random(int limit)
{
	 return rand()%limit;
}
#endif
//------------------------------------
//----END OF RANDOM LIBRARY-----------

>> srand((unsigned) time(&t));
you don't need the argument to time()

srand((unsigned) time(NULL));

>>#if defined(_MSC_VER)
delete the above line and the corresponding #endif. time functions and rand functions are both standard c/c++ library functions that are supported by most c or c++ compilers.

perfect. thnx! works like swiss watch

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.