954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

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 and #include i get these errors
1.cannot open include file cstdlib
2.call to undefined function rand
please help me with a solution

charles_wt
Newbie Poster
1 post since Nov 2004
Reputation Points: 10
Solved Threads: 0
 

I checked my old Borland C++ compiler, you may have to add the .h to your includes!

#include
#include

vegaseat
DaniWeb's Hypocrite
Moderator
5,989 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,417
 

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.

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 
I have borland C++ compiler on my system.while generating random numbers in C++,though i have incuded #include and #include 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

romerboy55
Newbie Poster
1 post since Feb 2008
Reputation Points: 10
Solved Threads: 0
 

I checked my old Borland C++ compiler, you may have to add the .h to your includes!

#include #include

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.

Obviouslyiostream 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

WaltP
Posting Sage w/ dash of thyme
Moderator
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You