My code works properly around 90% of the time, but randomly it'll crash with the following error. I've no idea what my issue is considering it works mostly. The goal is to create a square with randomly created dimensions from 0-9 in both width and height; each 'block' of the square contains another randomly generated number. Thanks for the help!
Following section of code:
srand(time(NULL));
int arrayX = rand() % 9;
int arrayY = rand() % 9;
int arrayShape[arrayX][arrayY];
cout << "Shape Length: " << arrayX << endl << "Shape Height: " << arrayY << endl;
int i;
int j;
for (i = 0; i < arrayY; i++)
{
for (j = 0; j < arrayX; j++)
{
arrayShape[i][j] = rand() % 9;
cout << arrayShape[i][j];
if (j == arrayX - 1) {
cout << endl;
}
}
}
Aucun commentaire:
Enregistrer un commentaire