www.digitalmars.com         C & C++   DMDScript  

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

reply %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.



begin 644 normmean.c
M(VEN8VQU9&4 /&UA=& N:#X-"B-I;F-L=61E(#QS=&1I;RYH/ T*(VEN8VQU
M9&4 /'-T9&QI8BYH/ T*(VEN8VQU9&4 /'1I;64N:#X-"B-I;F-L=61E(#QC
M;6%T:#X-" T*9&]U8FQE(&YO<FUR;F0H9&]U8FQE(&UU+&1O=6)L92!S:6=M
M82D-"GL-"B` ("` ("!D;W5B;&4 8VAI+&5T82QR970[#0H ("` ("` 8VAI
M/61R86YD-# H*3L-"B` ("` ("!E=&$]9')A;F0T." I.PT*("` ("` (')E
M=#UM=2MS:6=M82IS<7)T*"TR*FQO9RAC:&DI*2IC;W,H,BI-7U!)*F5T82D[
M#0H ("` ("` <F5T=7)N(')E=#L-"GT-" T*;6%I;B I#0I[#0H ("` ("!I
M;G0 :2P ;FUB<F]F<VEM.PT*("` ("` 9&]U8FQE('1I9"QE<W0L;74L<VEG
M;6$[#0H ("` ("!C;&]C:U]T('1I8VMS,2P =&EC:W,R.PT*("` ("` =6YS
M:6=N960 <VAO<G0 ;7ES965D.PT*#0H ("` ("!M>7-E960]-S4P.3L-"B` 
M("` ('-R86YD-# H;7ES965D*3L-" T*("` ("` ;74],"XP.PT*("` ("` 
M<VEG;6$],2XP.PT*("` ("` 97-T/3`N,#L-" T*("` ("` =&EC:W,Q/6-L
M;V-K*"DO0TQ/0TM37U!%4E]314,[#0H-"B` ("` (&YM8G)O9G-I;3TQ,#`P
M,#`P,#L-"B` ("` (&9O<BAI(#T ,#L :2`\(&YM8G)O9G-I;3L :2`](&D 
M*R`Q*0T*("` ("` >PT*("` ("` ("` ("` 97-T(#T 97-T("L ;F]R;7)N
M9"AM=2QS:6=M82D[#0H ("` ("!]#0H-"B` ("` (&5S="`](&5S="]N;6)R
M;V9S:6T[#0H-"B` ("` ('1I8VMS,CUC;&]C:R I+T-,3T-+4U]015)?4T5#
M.PT*("` ("` =&ED/61I9F9T:6UE*'1I8VMS,BP =&EC:W,Q*3L-" T*("` 
M("` <')I;G1F*")4:6UE(&ES("5F7&XB+"!T:60I.PT*("` ("` <')I;G1F
M*")%<W0 :7, )69<;B(L(&5S="D[#0H ("` ("!R971U<FX ,#L-"GT-" ``
`
end
Oct 06 2006
parent reply 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
parent reply 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
parent 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