Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #13382

Re: portable rand/srand across linux,windows,etc

From Eric Sosman <esosman@ieee-dot-org.invalid>
Newsgroups comp.lang.c
Subject Re: portable rand/srand across linux,windows,etc
Date 2011-11-15 08:01 -0500
Organization A noiseless patient Spider
Message-ID <j9tnri$md$1@dont-email.me> (permalink)
References <j9tngi$fm9$1@reader1.panix.com>

Show all headers | View raw


On 11/15/2011 7:55 AM, JohnF wrote:
> Sorry if the wrong ng (please suggest another).
> I'm looking for robustly portable stdlib entry points
> for rand()/srand() (e.g., or random()/srandom()),
> particularly across linux gcc and windows
> mingw and djgpp (and ms compilers).
> That is, I want to distribute one source, without
> a lot of pesky #ifdef's, to compile on all platforms.
> Would also be nice if portable across everything
> else from free/netbsd to vms/dec C, too, but linux
> and windows are the biggies. Google shows various
> occasional complaints about rand stuff not compiling and/or
> not working on windows. I don't need anything particularly
> good -- just naked eye random, so to speak. And if it's
> easier to just cut-and-paste source from Numerical Recipes,
> I'm okay with that, too.

     Every (hosted) C implementation supplies rand() and srand(),
both declared in <stdlib.h>.  The quality of the generated
numbers may vary from one implementation to the next, but should
suffice for "naked eye random."

-- 
Eric Sosman
esosman@ieee-dot-org.invalid

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

portable rand/srand across linux,windows,etc JohnF <john@please.see.sig.for.email.com> - 2011-11-15 12:55 +0000
  Re: portable rand/srand across linux,windows,etc Eric Sosman <esosman@ieee-dot-org.invalid> - 2011-11-15 08:01 -0500
  Re: portable rand/srand across linux,windows,etc Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-15 13:14 +0000
    Re: portable rand/srand across linux,windows,etc JohnF <john@please.see.sig.for.email.com> - 2011-11-15 13:46 +0000
      Re: portable rand/srand across linux,windows,etc Keith Thompson <kst-u@mib.org> - 2011-11-15 14:09 -0800
        Re: portable rand/srand across linux,windows,etc JohnF <john@please.see.sig.for.email.com> - 2011-11-16 03:45 +0000
          Re: portable rand/srand across linux,windows,etc Keith Thompson <kst-u@mib.org> - 2011-11-15 20:11 -0800

csiph-web