Code:
int main(){
int *map[12][12][5], monster = 0, mnstMdfy = 0,mnstDths[26];
mnstDths[6] = 0;
map[1][0][0] = (int *)malloc(sizeof(int));
map[1][0][0] = 71;
printf("\nMap = %d\n",map[1][0][0]);
monster = map[1][0][0] - 65;
printf("\nMonster = %d\n",monster);
mnstMdfy = mnstDths[monster] * 5;
printf("\nModifier = %d\n",mnstMdfy);
}
This is a rough outline of the actual code, but the given code should be sufficient. After running the program, the print statements have given me results such as...
"Map = 71
Monster = -189
Modifier = 335"
I've looked over this many times and cant seem to identify where the values of Monster and Modifier come from. They should be zero, but obviously that's not the case. Any help is appreciated!
EDIT: I have found that splitting the monster assignment into...
monster = map[1][0][0];
monster = monster - 65;
... fixes this problem, however I still am not sure as to why this occurs. (Maybe the 65 is changing the address?) Please let me know!