Greetings!
I am new to C++ and I am currently reading jumping into C++ featured on this website. I am reading about the rand and srand functions. The book claims you need a function prototype for these functions however when i input the prototypes my compiler gives me an error untill i comment out the prototypes. Is this expected and if so why? I have copied my code below to give an example with the offending code commented out.
Thank you for your help!
Code:#include <iostream> #include <cstdlib> #include <ctime> using namespace std; int main() { //void srand(int x);//function prototype to generate random seed. //int rand; // function prototype for random number generation. int random_seed = time( NULL ); // set random seed based on unix clock srand(random_seed); cout << rand() << "\n"; cout << rand() << "\n"; cout << rand() << "\n"; cout << rand() << "\n"; }



LinkBack URL
About LinkBacks



