need to see the maze and partial output expected, do you have a sample test case to run?
you can't add locations to an array, all you can do is index up to what it holds.
you can find its size, if you need that.
the size of an array: sizeof(arr)/sizeof(arr);
index can be static, but I don't know if that answers your question.
static int index = 0;
here index is the same variable across ALL the recursive calls.
to remove the last element if you got stuck, you just change the index backwards and the next valid entry will overwrite that. you can explicitly zero out that cell or whatever sentinel value you want to use to indicate 'invalid' so that if it finds the exit any subsequent data is marked invalid for you.
depending on what is in path, you can also brute force the thing. if path is an array of say 1000 ints, all of them initialized to say -42 which you have defined to mean 'invalid, unused cell' then you can do it via iteration too, fire off index at zero and iterate until the cell at the current index == -42 and you have found the next spot to write into, and can go backwards (if not at the initial location!) if there is nowhere to go from a step... the static idea eliminates the hunt and peck extra looping, is all.