hi everyone, i am fairly new to c++ and in one of my first works i had to implement the method "rand()" and since i had no idea how to use it i went looking for a tutorial and found this website.
the tutorial i am refering to is this one : http://www.cprogramming.com/tutorial/random.html
so i started reading it and when i got to the code part i copied it and tried to compile it but i got this problem :
../main.cpp: In function `int main()':
../main.cpp:23: error: `cout' undeclared (first use this function)
../main.cpp:23: error: (Each undeclared identifier is reported only once for each function it appears in.)
../main.cpp:23: error: `endl' undeclared (first use this function)
make: *** [main.o] Error 1
line 23 refers to this : cout << rand() << endl;
if you do not wish to go to the linked page here is the code :
any help will be much apreciated.Code:#include <iostream> #include <cstdlib> #include <time.h> int main() { /* Declare variable to hold seconds on clock. */ time_t seconds; /* Get value from system clock and place in seconds variable. */ time(&seconds); /* Convert seconds to a unsigned integer. */ srand((unsigned int) seconds); /* Output random values. */ cout << rand() << endl; cout << rand() << endl; cout << rand() << endl; return 0; }
thank you for the time spent reading my post



LinkBack URL
About LinkBacks



Quzah would scream at the indentation though.