Hello,
I'm quite new in C++ and I'm having a problem with a "Random walk in a 2 dimensional lattice with traps".
It doesn't appear to have any problems at the compiling, but when I'm trying to run the .exe an error message appears:
"An unhandled win32 exception occurred in *.exe. Just-In-Time debugging this exception failed with the following error: No installed debugger has Just-In-Time debugging enabled"
Is there anything wrong with my code that causes that error? Google didn't help me.
What you are seeing is a fatal error in your program, but the OS can't find a debugger to help you find the error. One thing that is probably a problem: You have times defined as having 1000 entries; however you are looping over it 100,000 times!
Those constants shouldn't be in global scope either if they're used in only one function.
There are more stylistical problems. In particular: don't declare variables before they're used, use fstreams instead fopen/printf, use vectors instead of allocating raw arrays (or when you do, delete[] them when you no longer need them) and here:
1 2 3 4
r=rand()% 1000;
x=r;
r=rand()% 1000;
y=r;
the intermediate assignments to r are unnecessary.
Remember that proper coding style avoids the vast majority of problems you would normally run into.