www.digitalmars.com         C & C++   DMDScript  

c++ - Random numbers

reply Monk <Monk_member pathlink.com> writes:
rand() and RAND_MAX don't seem to be available, or are they? What is the
equivalent of cstdlib.h?
Jun 04 2003
parent reply Heinz Saathoff <hsaat bre.ipnet.de> writes:
Monk schrieb...
 rand() and RAND_MAX don't seem to be available, or are they? What is the
 equivalent of cstdlib.h?

You include either <stdlib.h> or <cstdlib>, but not <cstdlib.h> (hope this is true for DM). - Heinz
Jun 05 2003
parent reply "Greg Peet" <admin gregpeet.com> writes:
Prepended header files with 'c' indicate the standardized ruling for using
the C runtime library (standard portions) with C++. Thus time becomes
<ctime> instead of <time.h>, <stdio.h> becomes <cstdio>, <stdlib.h> becomes
<cstdlib>, etc. Are you writing in C or C++? If it's C++, there should be no
.h (though you may sometimes, non-standard-ruled for some). Now if you are,
take into account which Standard Library you are using. I've had some
problems with namespaces with the SGI (which is why STLPort is available).

"Heinz Saathoff" <hsaat bre.ipnet.de> wrote in message
news:MPG.1949550a205d33d29896bd news.digitalmars.com...
 Monk schrieb...
 rand() and RAND_MAX don't seem to be available, or are they? What is the
 equivalent of cstdlib.h?

You include either <stdlib.h> or <cstdlib>, but not <cstdlib.h> (hope this is true for DM). - Heinz

Jun 06 2003
parent Heinz Saathoff <hsaat bre.ipnet.de> writes:
Greg Peet schrieb...
 Prepended header files with 'c' indicate the standardized ruling for using
 the C runtime library (standard portions) with C++. Thus time becomes
 <ctime> instead of <time.h>, <stdio.h> becomes <cstdio>, <stdlib.h> becomes
 <cstdlib>, etc. Are you writing in C or C++? If it's C++, there should be no
 .h (though you may sometimes, non-standard-ruled for some). Now if you are,
 take into account which Standard Library you are using. I've had some
 problems with namespaces with the SGI (which is why STLPort is available).

The difference between <cname> and <name.h> in C++ is that all identifiers (except macros) are in namespace std when <cname> is included and in global namespace if <name.h> is included. For now I still use the 'original' c-headers (old men move slowly <g>). - Heinz
Jun 06 2003