time based random number generator

I have my program set up with just the rand() in the desired function; however, I can't figure out how to implement time.h or srand() to get past the same repeating set of "random" numbers. I included all I thought was relevant.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <iostream>
#include <cstdlib>
using namespace std;

const int RANDOM_CNT = 50;
int randArr[RANDOM_CNT];
void GenerateRandom (int randArr[], int RANDOM_CNT);

int main()
{
	int i, x;
	GenerateRandom (randArr, RANDOM_CNT);
}

void GenerateRandom (int randArr[], RANDOM_CNT)
{
	int i, x;
	for (i = 0; i < RANDOM_CNT; i++)
	{
		x = (rand() % 49) + 1;
		randArr[i] = x;
		cout << randArr [i] << " ";
	}
}
write srand(time(NULL)); in main.
thanks, that worked
Topic archived. No new replies allowed.