DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   Compile time errors in C++ while generating random numbers (http://www.daniweb.com/forums/thread13324.html)

charles_wt Nov 2nd, 2004 3:06 am
Compile time errors in C++ while generating random numbers
 
I have borland C++ compiler on my system.while generating random numbers in C++,though i have incuded #include<cstdlib> and #include<iostream> i get these errors
1.cannot open include file cstdlib
2.call to undefined function rand
please help me with a solution

vegaseat Nov 2nd, 2004 12:07 pm
Re: Compile time errors in C++ while generating random numbers
 
I checked my old Borland C++ compiler, you may have to add the .h to your includes!

#include<iostream.h>
#include<cstdlib.h>

alc6379 Nov 2nd, 2004 3:53 pm
Re: Compile time errors in C++ while generating random numbers
 
Can you please post your code here? That second part looks like you've not defined a function or something. Perhaps you've misnamed a function that you created, or you're #including a wrong library or something. Either way, post your code, and we'll be able to help you troubleshoot it.

romerboy55 Feb 9th, 2008 9:02 pm
Re: Compile time errors in C++ while generating random numbers
 
Quote:

Originally Posted by charles_wt (Post 64677)
I have borland C++ compiler on my system.while generating random numbers in C++,though i have incuded #include<cstdlib> and #include<iostream> i get these errors
1.cannot open include file cstdlib
2.call to undefined function rand
please help me with a solution

as for the second error its because your calling rand() which is in the file math.h try including that the compile again

WaltP Feb 9th, 2008 10:05 pm
Re: Compile time errors in C++ while generating random numbers
 
Quote:

Originally Posted by vegaseat (Post 64775)
I checked my old Borland C++ compiler, you may have to add the .h to your includes!

#include<iostream.h>
#include<cstdlib.h>

Quote:

Originally Posted by romerboy55 (Post 531005)
as for the second error its because your calling rand() which is in the file math.h try including that the compile again

Ahhh, all these clueless people.

Obviously iostream worked. But cstdlib didn't. Change it to stdlib.h instead. We won't even mention math.h

You might consider upgrading to at least Borland 5.5

Or one of these that have an IDE:
Code::Blocks
MSVC++ Express
Open Watcom C++/Fortran
Bloodshed DevC


All times are GMT -4. The time now is 2:34 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC