Random.h

This is a discussion on Random.h within the C++ Programming forums, part of the General Programming Boards category; I am trying to use the randomize function but I don't seem to have the random.h library. I am using ...

  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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,434
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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

    Is that what you are after?

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21