Thread: Random.h

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    31

    Random.h

    I am trying to use the randomize function but I don't seem to have the random.h library. I am using Visual Studio 6.0. Can someone tell me where I could download this library so I can utilize this function.

    TIA

  2. #2
    Cheesy Poofs! PJYelton's Avatar
    Join Date
    Sep 2002
    Location
    Boulder
    Posts
    1,728
    I wasn't aware there was a random.h header file. This should work fine:

    Code:
    #include<time.h>
    #include<iostream>
    using namespace std;
    
    int main()
    {
          srand(time(NULL));
          int x=rand()%100;   // random number from 0-99
          cout<<x<<endl;
          return 0;
    }

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    The ANSI rand() and srand() are in
    #include <cstdlib>
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Err...there's boost/random.hpp under the boost library?

    Is that what you are after?

Popular pages Recent additions subscribe to a feed