c++ - Why doesn't drand48() and srand48() work.
- %u (35/35) Oct 06 2006 Excuse me, I am no experienced C programmer, but I really need help.
- Walter Bright (2/5) Oct 06 2006 srand48 and drand are not standard C functions.
- Mill-Creeks (3/3) Oct 07 2006 Thank you very much for your reply, Walter Bright!
- Walter Bright (3/7) Oct 07 2006 You could switch to using the C standard random number generator rand()
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 M=#UM=2MS:6=M82IS<7)T*"TR*FQO9RAC:&DI*2IC;W,H,BI-7U!)*F5T82D[ M;G0 :2P ;FUB<F]F<VEM.PT*("` ("` 9&]U8FQE('1I9"QE<W0L;74L<VEG M<VEG;6$],2XP.PT*("` ("` 97-T/3`N,#L-" T*("` ("` =&EC:W,Q/6-L M*R`Q*0T*("` ("` >PT*("` ("` ("` ("` 97-T(#T 97-T("L ;F]R;7)N 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 ` end
Oct 06 2006
%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
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
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