This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


On 9/8/10, Václav Haisman <v.haisman@whithaus.giv> wrote:
> -----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
goog:

http://www.google.com/#sclient=psy&hl=en&q=rand%28%29+include+header&aq=f&aqi=&aql=&oq=&gs_rfai=&pbx=1&fp=fb33825a2a74a863

also I'd mention that grepping in the include path can work.

--
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]