943,383 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 7100
  • C++ RSS
Nov 2nd, 2004
0

Compile time errors in C++ while generating random numbers

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
charles_wt is offline Offline
1 posts
since Nov 2004
Nov 2nd, 2004
0

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>
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Nov 2nd, 2004
0

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.
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003
Feb 9th, 2008
0

Re: Compile time errors in C++ while generating random numbers

Click to Expand / Collapse  Quote originally posted by charles_wt ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
romerboy55 is offline Offline
1 posts
since Feb 2008
Feb 9th, 2008
0

Re: Compile time errors in C++ while generating random numbers

Click to Expand / Collapse  Quote originally posted by vegaseat ...
I checked my old Borland C++ compiler, you may have to add the .h to your includes!

#include<iostream.h>
#include<cstdlib.h>
Click to Expand / Collapse  Quote originally posted by romerboy55 ...
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
Last edited by WaltP; Feb 9th, 2008 at 10:06 pm.
Moderator
Reputation Points: 3275
Solved Threads: 889
Posting Sage
WaltP is offline Offline
7,708 posts
since May 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: FindFirstFile()
Next Thread in C++ Forum Timeline: if statement involving array of a class (C2451)





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC