www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - Why doesn't drand48() and srand48() work.

↑ ↓ ← %u <petermnemonic hotmail.com> writes:
Excuse me, I am no experienced C programmer, but I really need help.
I've installed DMC and if I write a program normmean.c containing this lines;

      unsigned short myseed;
      myseed=750908;
      srand48(myseed);

...and also:

      double chi;
      chi=drand48();

.. I get an error when compiling. Running "dmc normmean" yields

"normmean.obj(normmean) Error 42: Symbol Undefined _srand48" and equally for
"_drand". What is wrong? The same program (attached) worked well when compiled
with gcc at my school.
Oct 06 2006
↑ ↓ Walter Bright <newshound digitalmars.com> writes:
%u wrote:
 "normmean.obj(normmean) Error 42: Symbol Undefined _srand48" and equally for
 "_drand". What is wrong? The same program (attached) worked well when compiled
 with gcc at my school.

srand48 and drand are not standard C functions.
Oct 06 2006
↑ ↓ Mill-Creeks <petermnemonic hotmail.com> writes:
Thank you very much for your reply, Walter Bright!

How may I access drand48() and srand48() then? I thought they would come with
"#include <stdlib.h>".
Oct 07 2006
↑ ↓ → Walter Bright <newshound digitalmars.com> writes:
Mill-Creeks wrote:
 Thank you very much for your reply, Walter Bright!
 
 How may I access drand48() and srand48() then? I thought they would come with
 "#include <stdlib.h>".

You could switch to using the C standard random number generator rand() and srand().
Oct 07 2006