srand compiler error

Hello all, I am trying to make a player vs computer tic tac toe game, and it runs a couple turns and then gets an error:
Unhandled Exception: 0xC0000005: Access Violation writing location 0x00390F94

And the breakpoint points to

1
2
3
4
static __inline time_t __CRTDECL time(time_t * _Time)
{
    return _time64(_Time);
}


within the time.h library
Here is my code for the member function so far... it works so far up to this point

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#define SEED NULL
.
.
.

char Draw::randomCell()
{
	int random;
	//makes the seed time different every time it is run
	srand(time(SEED));
	random = 1 + (rand() % (57 - 48) + 48);		//picks a random number from 1-9
	char randomChar = static_cast<char>(random);	//converts random number to applicable char
	if (!isSame(randomChar))
		return randomChar;
	else
		randomCell();
}
http://www.cplusplus.com/forum/general/112111/

1
2
	//makes the seed time different every time it is run
	srand(time(SEED));
unless at least 1 second pass between the calls, that is not what is going to happen..
you should srand() call just one time.

1
2
//random = 1 + (rand() % (57 - 48) + 48);
random = 1 + rand() % ('9' - '0') + '0';


> And the breakpoint points to
look at the call stack
Topic archived. No new replies allowed.