I have a run time issue when i debugged my script.
It says :
Unhandled exception at 0x002a4f8e in test2.exe: 0xC0000094: Integer division by zero.
Although the line in question is a rand number generation.
if((rand() % miss) < 3){ //line 40
int phit = (rand()% hit);
} else {
bool pmiss = true;
}
Debugger stops at line 40 when it goes wrong (which i labelled above).
My full script is here:
http://www.paste.to/MzQ1ODM1
How should I have written the if statement if this causes such an error, i keep thinking like a PHP programmer which is v.frustrating to adapt!
You are re-declaring
missat line 30. That variable will be local to the if statement. Therefore, the globalmisswill still have a value of zero. Take out all thoseint, and also theboolinside theifstatements! Like this: