Tuesday, July 14, 2009

Why rand() doesn't work in visual studio??

I am using visual studio 2005 for c++ programming.... I tried to use rand() function to generate a random number in a win32 console application but i recieve an error that says identifier ( rand ) not found!!!


That means that it doesn't even exist.... What is the problem??





I remember also that when i try to copy source codes from a website, some libraries return an error saying that they are not found such as iostream.h.... and functions such as cout (although i don't know what it means yet!!!





Thanks in advance......... :):):):)

Why rand() doesn't work in visual studio??
You need to #include %26lt;math.h%26gt; for rand().





As for compiling other people's source, it isn't clear why Visual Studio wouldn't find something like iostream.h. VS should be set up to know where that is by default. The first thing I would do is go into "Options..." and find where your include file directories are set, and make sure there's a line that says "$(VCInstallDir)include" (without the quotes). See if that helps.

apricot

No comments:

Post a Comment