> #include <iostream>
#include <cstdlib>
int main()
{
std::srand( 222 );
std::cout << std::rand() << "\n";
}
Upon compling (in MSVC) it returned the error:
Compiling...
c:\random.cpp
c:\random.cpp(2) : fatal error C1083: Cannot open include file: 'cstdlib.h':
No such file or directory
CL returned error code 2.
RANDOM.CPP - 1 error(s), 0 warning(s)
that was after placing a '.h' after iostream and cstdlib. Before doing this
returned this error:
Compiling...
c:\random.cpp
c:\random.cpp(1) : fatal error C1083: Cannot open include file: 'iostream':
No such file or directory
CL returned error code 2.
RANDOM.CPP - 1 error(s), 0 warning(s)
There are seven errors and one warning when an attempt at compiling is made
with the absence of the line '#include<cstdlib.h>'. These are:
Compiling...
c:\random.cpp
c:\random.cpp(6) : error C2653: 'std' : is not a class name
c:\random.cpp(6) : error C2065: 'srand' : undeclared identifier
c:\random.cpp(6) : error C2064: term does not evaluate to a function
c:\random.cpp(8) : error C2653: 'std' : is not a class name
c:\random.cpp(8) : error C2653: 'std' : is not a class name
c:\random.cpp(8) : error C2065: 'rand' : undeclared identifier
c:\random.cpp(8) : error C2064: term does not evaluate to a function
c:\random.cpp(9) : warning C4508: 'main' : function should return a value;
'void' return type assumed
CL returned error code 2.
RANDOM.CPP - 7 error(s), 1 warning(s)
Could you please give me code for a working program that I can compile in
either borland and/or msvc (v1.5) (note they are both old versions) that
will generate three random numbers, to be placed in three different integers
and then displayed to the screen. Thank you.