Language: C

/*  ex7_3
    yy8332  */

#include <stdio.h>

int main(void){
  int height, width, i, j, k, num = 0;
  int i, j, row, column;
  char **multi_array;

  //入力読み取り
  scanf("%d %d", &height, &width);

  //各行の配列へのポインタ分のメモリ領域を確保
  multi_array = (char**)calloc(height, sizeof(char*));
  if(multi_array == NULL){
      fprintf(stderr, "calloc error.\n");
      exit(1);
  }
  //各行の要素分のメモリ領域を確保
  for(i = 0; i < row; i++){
      multi_array[i] = (char*)calloc(width, sizeof(char));
      if(multi_array[i] == NULL){
          fprintf(stderr, "calloc error.\n");
          exit(1);
      }
  }

  for(i = 0; i < height; i++){
    for(j = 0; j < width; j++){
      scanf(" %c", &multi_array[i][j]);
    }
  }

  //横の操作
  for(i = 0; i < height; i++){

    for(j = 0; j < width; j++){
      if(multi_array[i][j] == '#'){
        num = 1;
      }
    }

    if(num == 0){
      height -= 1;
      for(k = i; k < height; k++){
        for(j = 0; j < width; j++){
          multi_array[k][j] = multi_array[k + 1][j];
        }
      }
      i -=1;
    }
    num = 0;
  }

  //縦の操作
  for(j = 0; j < width; j++){

    for(i = 0; i < height; i++){
      if(multi_array[i][j] == '#'){
        num = 1;
      }
    }

    if(num == 0){
      width -= 1;
      for(k = j; k < width; k++){
        for(i = 0; i < height; i++){
          multi_array[i][k] = multi_array[i][k + 1];
        }
      }
      j -=1;
    }
    num = 0;
  }


  //出力
  for(i = 0; i < height; i++){
    for(j = 0; j < width; j++){
      printf("%c", multi_array[i][j]);
    }
    printf("\n");
  }

  //メモリ領域の解放，各行の要素分の領域を開放し，
  //各行の配列へのポインタの領域を解放
  //（メモリ領域の確保と逆順）
  for(i = 0; i < row; i++){
      free(multi_array[i]);
  }
  free(multi_array);


  return 0;
}


Compiler output:
main.c: In function 'main':
main.c:8:7: error: redeclaration of 'i' with no linkage
    8 |   int i, j, row, column;
      |       ^
main.c:7:22: note: previous declaration of 'i' with type 'int'
    7 |   int height, width, i, j, k, num = 0;
      |                      ^
main.c:8:10: error: redeclaration of 'j' with no linkage
    8 |   int i, j, row, column;
      |          ^
main.c:7:25: note: previous declaration of 'j' with type 'int'
    7 |   int height, width, i, j, k, num = 0;
      |                         ^
main.c:15:25: error: implicit declaration of function 'calloc' [-Wimplicit-function-declaration]
   15 |   multi_array = (char**)calloc(height, sizeof(char*));
      |                         ^~~~~~
main.c:5:1: note: include '<stdlib.h>' or provide a declaration of 'calloc'
    4 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    5 | 
main.c:15:25: warning: incompatible implicit declaration of built-in function 'calloc' [-Wbuiltin-declaration-mismatch]
   15 |   multi_array = (char**)calloc(height, sizeof(char*));
      |                         ^~~~~~
main.c:15:25: note: include '<stdlib.h>' or provide a declaration of 'calloc'
main.c:18:7: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
   18 |       exit(1);
      |       ^~~~
main.c:18:7: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:18:7: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
main.c:18:7: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:25:11: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
   25 |           exit(1);
      |           ^~~~
main.c:25:11: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:90:7: error: implicit declaration of function 'free' [-Wimplicit-function-declaration]
   90 |       free(multi_array[i]);
      |       ^~~~
main.c:90:7: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c:90:7: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
main.c:90:7: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c:92:3: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
   92 |   free(multi_array);
      |   ^~~~
main.c:92:3: note: include '<stdlib.h>' or provide a declaration of 'free'