I am studying from a book that was written in 2008. In the book they use srand like this:
Non of that would run on my machine. I had to write it like this:Code:#include <stdio.h> main() { int var = 0; srand(time()); rand(time() % 10 + 1; ...
1. Why did I have to add the extra header files #include <stdlib.h>Code:#include <stdio.h> #include <stdlib.h> #include <time.h> main() { int var = 0; srand(time(NULL)); rand(time() % 10 + 1; ...
and #include <time.h>?
2. Why did I have to add NULL as an argument to the rand function?
3. Why is 'rand(time(NULL))' not written with the 's' like this: 'srand(time(NULL))'?