How can I use random numbers in Linux and C++?
I have found some code I would like to use, it has the line
srand((unsigned)time(0));//seed
but gcc says
board.cpp:94:24: error: ‘time’ was not declared in this scope
I have included the following files
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
You haven’t included the header that defines the function, in order for your program to know how to call time() you need to add this include:
and just to nitpick (code style) your call should more correctly be time(NULL) instead of time(0)