hey, i have been coding an algorithim which i think is correct and will do the job, but i keep getting lost when it comes time to pop the stack, im not sure if im addressing the pointers correctly as they dont seem to update when popped off the stack, yet the stack still decrements each pop.


Code:
#include <stdio.h>
#include "stacksADT.h"
int maze[12][29]={{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                  {1,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1},
                  {1,1,1,1,1,0,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1},
                  {1,0,0,0,0,0,1,1,1,1,1,1,0,1,1,1,0,1,1,1,1,1,1,1,0,0,0,0,9},
                  {0,0,1,1,1,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1},
                  {1,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1},
                  {1,0,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,0,1,1,1,1,1,1},
                  {1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1},
                  {1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                  {1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                  {1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                  {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}};
int sel;
int temp;

int main(){
    int* y;
    int* x;
    STACK* travelledx;
    STACK* travelledy;
    int t;
    travelledx = createStack();
    travelledy = createStack();
    y = (int*) malloc (sizeof (int));
    x = (int*) malloc (sizeof (int));
    *y = 4;
    *x = 0;
for (t=0; t=1000; t++){
    switch(maze[*y][*x])
      {
       case 0:
            *y = *y+1;
            if (maze[*y][*x] == 0){
               pushStack(travelledy, y);
               pushStack(travelledx, x);
               maze[*y][*x] = 2;}
            else {
                 *y = *y-2;
                 if (maze[*y][*x] == 0){
                    pushStack(travelledy, y);
                    pushStack(travelledx, x);
                    maze[*y][*x] = 2;}
                 else {
                      *y = *y+1;
                      *x = *x+1;
                      if (maze[*y][*x] == 0){
                         pushStack(travelledy, y);
                         pushStack(travelledx, x);
                         maze[*y][*x] = 2;}
                      else {
                           *x = *x-2;
                           if (maze[*y][*x] == 0){
                              pushStack(travelledy, y);
                              pushStack(travelledx, x);
                              maze[*y][*x] = 2;}
                           else {
                           *x = *x+1;
                           }
                      }
                 }
            }
       printf("moved");     
       break;
       case 1:
            x = popStack(travelledx);
            y = popStack(travelledy);
       break;
       case 2:
            *y = *y+1;
            if (maze[*y][*x] == 0){
               pushStack(travelledy, y);
               pushStack(travelledx, x);
               maze[*y][*x] = 2;}
            else {
                 *y = *y-2;
                 if (maze[*y][*x] == 0){
                    pushStack(travelledy, y);
                    pushStack(travelledx, x);
                    maze[*y][*x] = 2;}
                 else {
                      *y = *y+1;
                      *x = *x+1;
                      if (maze[*y][*x] == 0){
                         pushStack(travelledy, y);
                         pushStack(travelledx, x);
                         maze[*y][*x] = 2;}
                      else {
                           *x = *x-2;
                           if (maze[*y][*x] == 0){
                              pushStack(travelledy, y);
                              pushStack(travelledx, x);
                              maze[*y][*x] = 2;}
                           else {
                                *x = *x+1;
                                temp = stackCount(travelledx);
                                free(x);
                                free(y);
                           	    x = (int*)popStack (travelledx);
                                y = (int*)popStack (travelledy);
                                temp = stackCount(travelledx);
                                }
                      }
                 }
            }
       printf("moved");
       break;
       case 9:
            t = 1000;
            printf("Winner!");
       break;
       }
}
return 0;
}