This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Re: rand() was not declared in this scope, please help‏
- From: VÃclav Haisman <v dot haisman at sh dot cvut dot cz>
- To: cygwin at cygwin dot com
- Date: Wed, 08 Sep 2010 19:38:34 +0200
- Subject: Re: rand() was not declared in this scope, please help‏
- References: <CD7CFA1134410784EA0A1AA09A4D2A5B@ericlin.fsshl.zzn.com>
- Reply-to: cygwin at cygwin dot com
-----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