Language: C

/*ex7_3
 Sweet_Sweet_Soul */
#include <stdio.h>

int main(void) {
    int hei,wid;/*hei=height、wid＝width*/
    int *hei_ture,*wid_ture;/*各行や列に'#'があれば1を記録する配列*/
    char **grid;/*入力用の多次元配列*/
    scanf("%d%d",&hei,&wid);
    grid=(char**)calloc(hei,sizeof(char*));/*まず各配列の先頭のポインタを確保*/
    if(grid==NULL){
        exit(1);
    }
    for(int i=0;i<hei;i++){
        grid[i]=(char*)calloc(wid,sizeof(char));/*各配列の要素を確保*/
        if(grid[i]==NULL){
            exit(1);
        }
    }
    hei_ture=(int*)calloc(hei,sizeof(int));/*他二つのtrue配列も確保*/
    if(hei_ture==NULL){
        exit(1);
    }
    wid_ture=(int*)calloc(wid,sizeof(int));
    if(wid_ture==NULL){
        exit(1);
    }
    for(int i=0;i<hei;i++){
        for(int j=0;j<wid;j++){
            scanf(" %c",&grid[i][j]);
            if(grid[i][j]=='#'){
                hei_ture[i]=1;/*真偽値を記録*/
                wid_ture[j]=1;
            }
        }
    }
    for(int i=0;i<hei;i++){
        if(hei_ture[i]==1){
            for(int j=0;j<wid;j++){
                if(wid_ture[j]==1){
                    printf("%c",grid[i][j]);/*行、列ともに真偽値1なら出力*/
                }
            }
        printf("\n");/*行ごとに改行*/
        }
    }
    /*先に各要素の配列のメモリを解放*/
    if(int i=0;i<hei,i++){
        free(grid[i]);
    }
    /*次に先頭のポインタを解放*/
    free(grid);
    free(hei_ture);
    free(wid_ture);
    return 0;
}


Compiler output:
main.c: In function 'main':
main.c:10:18: error: implicit declaration of function 'calloc' [-Wimplicit-function-declaration]
   10 |     grid=(char**)calloc(hei,sizeof(char*));/*まず各配列の先頭のポインタを確保*/
      |                  ^~~~~~
main.c:4:1: note: include '<stdlib.h>' or provide a declaration of 'calloc'
    3 | #include <stdio.h>
  +++ |+#include <stdlib.h>
    4 | 
main.c:10:18: warning: incompatible implicit declaration of built-in function 'calloc' [-Wbuiltin-declaration-mismatch]
   10 |     grid=(char**)calloc(hei,sizeof(char*));/*まず各配列の先頭のポインタを確保*/
      |                  ^~~~~~
main.c:10:18: note: include '<stdlib.h>' or provide a declaration of 'calloc'
main.c:12:9: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration]
   12 |         exit(1);
      |         ^~~~
main.c:12:9: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:12:9: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
main.c:12:9: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:17:13: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
   17 |             exit(1);
      |             ^~~~
main.c:17:13: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:22:9: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
   22 |         exit(1);
      |         ^~~~
main.c:22:9: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:26:9: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch]
   26 |         exit(1);
      |         ^~~~
main.c:26:9: note: include '<stdlib.h>' or provide a declaration of 'exit'
main.c:48:8: error: expected expression before 'int'
   48 |     if(int i=0;i<hei,i++){
      |        ^~~
main.c:49:9: error: implicit declaration of function 'free' [-Wimplicit-function-declaration]
   49 |         free(grid[i]);
      |         ^~~~
main.c:49:9: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c:49:9: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
main.c:49:9: note: include '<stdlib.h>' or provide a declaration of 'free'
main.c:49:19: error: 'i' undeclared (first use in this function)
   49 |         free(grid[i]);
      |                   ^
main.c:49:19: note: each undeclared identifier is reported only once for each function it appears in
main.c:52:5: warning: incompatible implicit declaration of built-in function 'free' [-Wbuiltin-declaration-mismatch]
   52 |     free(grid);
      |     ^~~~
main.c:52:5: note: include '<stdlib.h>' or provide a declaration of 'free'