I need help with figuring out what exactly is this error and why is it occuring. When I debud the program everything seems to be working perfectly fine! I do not get this.
Code:
void WordsRandom()
{
srand((unsigned)time(NULL));
n = rand() % 10;
checkRandom[k] = n; //ERROR HERE --> THREAD 1: EXC_BAD_ACCESS
k ++; //k is set to 0 originally
rowRandom = getRandomNumber();
colRandom = getRandomNumber();
}
I do not know why this is happening. As far as I know, in this case there is no need to use the %d
specifier right? I f you require further code just let me know.
WordsRandom
is being called by other methods:
void horizontalOrientation()
{
size = (int)strlen(words[n]);
if((colRandom + (size - 1)) <= 9)
{
for(int j = 0; j < (strlen(words[n])); j ++)
{
puzzle[rowRandom][colRandom] = words[n][j];
colRandom ++;
}
}
else
{
do
{
WordsRandom();
horizontalOrientation();
}while((colRandom + (size - 1)) > 9);
}
}
I have other functions similiar to this for vertical and diagonal orientation.