Hi, I already posted another topic about this program, but since then, I have done more work on it and added monsters into the program. This completely messed everything up, and whenever I tried to run the program, it terminates with status -1073741819. I didn't have the slightest idea what that meant. I tried running the debugger on the program, and I got this error, Program received signal SIGSEGV, Segmentation fault. I also don't have the slightest idea what that means. Could someone please explain to me what the problem is, and give me some tips on how to solve it. Thanks!
What compiler / IDE are you using? Technically you shouldn't be able to compile this at all, because on line 32 you're attempting to create an array of non-const size on the stack.
The major problems I see cody and xism already mentioned.
line 32 should be: monster *monsters = new monster[numOfMonsters];
Then when you call line 33 outputBoard(monsters); and get to board [monsters[x].monsterRow] [monsters[x].monsterColumn] = 'X'; you are going to be placing x's at random out of bounds locations more than likely. You never assigned rows/columns for the monsters. The compiler can't read minds it has no idea where you want them to be.
Again you must give the locations before calling the output.
1 2 3 4 5 6 7
outputBoard(monsters); //should be after the next part
srand(time(NULL));
for (int x = 0; x<numOfMonsters; ++x)
{
monsters[x].monsterRow = rand() % 8;
monsters[x].monsterColumn = rand() % 21;
}
Also I see you use srand multiple times. You only need to call that once to seed the original pseudo-random sequence.