CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 1999
    Posts
    24

    srand() and rand() functions

    Hi all,

    Is the srand() and rand() functions in VC++ an ANSI standard? Can I assume that if I were to use any other C compiler, the generated sequence of random number will be the same?

    Does anyone know or has the source code of any random number generator that allows seeding?

    Thanks in advance for any help.


    Gladywin


  2. #2
    Join Date
    May 1999
    Location
    Jerusalem, Israel
    Posts
    251

    Re: srand() and rand() functions

    The rand and srand are ANSI standard functions for random number generator, but I don't think that ANSI tells to compiler developers, which algorithm to implement in this generator. So, it guarantees to you than rand or srand call will give you random number, but it doesn't guarantees to you that these numbers will be same on all compiler.
    And if you search for random number generator algorythm, there are a lot of them. For example, look at Random number page in Yahoo : http://dir.yahoo.com/Science/Mathema...andom_Numbers/.


    Jack.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured