Language: C

#include<stdio.h>
#include<stdlib.h>

#define MAX 20

// ????????¨?????¨ ?§???????
typedef struct {
  int row;               // ?????????
  int col;               // ?????????
} Coord;

// ??????????????¨ ?§???????
typedef struct _stack {
  struct _stack *next;
  Coord point;
} *stack, stackelem;

char M[MAX+2][MAX+2];    // ?????¢?????°??????????????§???

// ????????????????????£?¨?
int solve (int W, int H);
int search_df (int W, int H, Coord start);

// ??????????????¨
stack  new_stack (void);
int is_empty (stack);
int push (stack, Coord);
Coord top (stack);
Coord pop (stack);

// main ??¢??°
int main () {
  while (1) {
    int W, H;
    scanf("%d%d", &W, &H);
    if (W==0 && H==0) break;
    printf("%d\n", solve(W,H));
  }

  return 0;
}

// ?????£?????¢?´¢ 
int solve (int W, int H) {
  Coord start;             // ??????????????°???
  int i, j;

  //  ?£?????????????????¨???? 
  for (i=0; i<=W+1; i++) { M[0][i] = '#'; M[H+1][i] = '#'; }
  for (i=1; i<=H; i++) { M[i][0] = '#'; M[i][W+1] = '#'; }
  // ??????????????\??? 
  for (i=1; i<=H; i++) {
    for (j=1; j<=W; j++) {
      scanf(" %c", &M[i][j]);
      if (M[i][j]=='@') {
	start.row = i;
	start.col = j;
      }
    }
  }

  return search_df(W, H, start);
}

int search_df (int W, int H, Coord start) {
  stack S = new_stack ();  // ?¨?????????????????????????????????????
  int c = 1;               // ????????????????????????????????°???????????? 1 ??§?????????
  // ??????????????°???????¨????
  push(S,start);                               // ??????????????°?????? push
  // ??¢?´¢
  while (!is_empty(S)) {
    Coord current = pop(S);                    // pop ???????????????
    int d;                                     // ??????
    int D1[]={1,0,-1,0}; int D2[]={0,-1,0,1};  // ????????¢?????¶?????¨
    for (d=0; d<4; d++) {
      Coord nc = current;                      // Next Cell
      nc.row += D1[d];  nc.col += D2[d]; 
      if (M[nc.row][nc.col] == '.') {
	M[nc.row][nc.col] = '*';               // ?????°???????????°?????????
	c++;                                   // ???????????????????????????????????????
	push(S,nc);
      } // nc ????????¢?´¢?????? (*) ????£? (#) ?????´?????????????????????
    } 
  }
  return c;  // ??°??????????????????????????°?????????
}

/* ??°??????????????????????¢?????????????????????? */
stack new_stack (void) {
  stack s;
  s = (stack) malloc (sizeof (stackelem));
  if (s == NULL) return NULL;
  s->next = NULL;
  return s;
}
    
/* ???????????????????????????????????? */
int is_empty (stack s) {
  return (s && s->next == NULL);
}

/* ??°??????????´???????????????\ */
int push (stack s, Coord v) {
  stack p;
  if (s == NULL) return 0;
  p = (stack) malloc (sizeof (stackelem));
  if (p == NULL) return 0;
  p->point = v;
  p->next = s->next;
  s->next =  p;
  return 1;
}

/* ?????????????´?????????? */
Coord top (stack s) {
  if (s && s->next) 
    return s->next->point;
  exit (1);
}

/* ????????? */
Coord pop (stack s) {
  stack p;
  Coord v = top (s);
  p = s->next;
  s->next = p->next;
  free (p);
  return v;

Compiler output:
main.c: In function 'pop':
main.c:128:3: error: expected declaration or statement at end of input
  128 |   return v;
      |   ^~~~~~