Escaping from the labyrinth

Hello.
I'm having troubles with getting a program to work.
It has to return how many steps is takes to get out of the labyrinth or a sentence "You won't escape".
The user types in: sizes of the labyrinth x * y, the positions of start and exit and the labyrinth itself ( where -5 is start/exit, -1 is a wall and 0 is a corridor).
For example:
3 5
0 0 2 4
-5 0 0 0 0
0 -1 -1 -1 0
0 0 0 0 -5

This program would be easier to read if you used array semantics instead of pointers. So replace this:

Code:

*(*(t+0)+i) = -1;

with whichever of the following two statements is correct:

Code:

t[0][i] = -1;
t[i][0] = -1;

and repeat throughout the program.

Don't do this:

Code:

if(e1 < 0 or e2 < 0 or e1 > n-2 or e2 > m-2 or...

Just learn that || means OR and use || instead of some dumb #define that makes the program look more like Pascal or whatever (because it doesn't, and just ends up making your code harder to read). This code is perfectly readable:

Code:

if(e1 < 0 || e2 < 0 || e1 > n-2 || e2 > m-2 ||...

If your program has crashed then there's a good chance you've stuffed up your memory usage. So for example you might have confused:

Code:

int t[6][20];

with

Code:

int t[20][6];

If you really want to manage your arrays at a low level instead of using [][] syntax then just allocate 6*20 ints and address them with x+y*20 syntax instead of all this *(t+this)+that+(*)the**(*)+other*(*) or whatever shit you have to type to do what the compiler does automatically for you when you do t[a][b].