#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
void seedRandom()
{
srand(time(NULL));
}
double nextRandom()
{
seedRandom();
double ran;
ran = ( (double) rand()) / RAND_MAX;
cout << ran;
return ran;
}
int main()
{
cout<<nextRandom;
}
Why does this print 1 every time and not a random number between 0 and 1? I looked everywhere but it does not seem to work. This is due at midnight. Also, this is only an excerpt from a long code.