rand() was not declared in this scope, please help‏

Václav Haisman v.haisman@sh.cvut.cz
Wed Sep 8 18:15:00 GMT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

eric lin wrote, On 8.9.2010 19:35:
> dear cygwin/gcc users:
>  
>   I compile a simple code which i copied from a book, "The Complete Reference of C++"  Fourth Edition by Herbert Schildt in page 575, rand()
> which is clearly not be included in
> #include <iostream>
>  
> I tried 
> #inlcude <cmath>
>  
> it still not compile, i.e. same compile error
>  
> please help(see which lib I should include)
> /* I tried in ubuntu linux on my laptop, it also not compile by same reason */
You need to #include <cstdlib> and use std::rand().

- -- 
VH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iF4EAREIAAYFAkyHyhoACgkQeqrf2dJjGj4mMwD+L7zWAHf7L34vlph03R5TY4Rw
pizg2rsAWzelNkZHYGoBAMMSTJU7BF65E84+U5SAn2avkW/ZNGnGsj/aHeRnZHex
=4x2u
-----END PGP SIGNATURE-----

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list