Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    char box[100][100] = {'.'};
    rep(i,h){
        string s;
        cin >> s;
       rep(j,w) {
           box[i+1][j+1] = s[j];
        }
    }

    for(int i=1;i<h+1;i++) {
        for(int j=1;j<w+1;j++){
            if (box[i][j]=='#') {
                cout<<'#';
                continue;
            }

            int ans=0;
            if (box[i-1][j-1] == '#'){
              ans++;
            }
            if (box[i][j-1] == '#'){
              ans++;
            }
            if (box[i+1][j-1] == '#'){
              ans++;
            }
            if (box[i-1][j] == '#'){
              ans++;
            }
            if (box[i+1][j] == '#')[
              ans++;
              }
            if (box[i-1][j+1] == '#'){
              ans++;
            }
            if (box[i][j+1] == '#')[
              ans++;
              }
            if (box[i+1][j+1] == '#'){
              ans++;
            }
            cout<<ans;
        }

        cout << endl;
    }

    return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:39:18: error: expected ',' before '++' token
   39 |               ans++;
      |                  ^~
      |                  ,
a.cc:39:18: error: expected identifier before '++' token
   39 |               ans++;
      |                  ^~
a.cc:39:20: error: expected ']' before ';' token
   39 |               ans++;
      |                    ^
      |                    ]
a.cc: In lambda function:
a.cc:39:20: error: expected '{' before ';' token
a.cc: In function 'int main()':
a.cc:41:26: error: 'j' was not declared in this scope
   41 |             if (box[i-1][j+1] == '#'){
      |                          ^
a.cc:42:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   42 |               ans++;
      |               ^~~
      |               abs
a.cc:44:24: error: 'j' was not declared in this scope
   44 |             if (box[i][j+1] == '#')[
      |                        ^
a.cc:45:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   45 |               ans++;
      |               ^~~
      |               abs
a.cc:45:18: error: expected ',' before '++' token
   45 |               ans++;
      |                  ^~
      |                  ,
a.cc:45:18: error: expected identifier before '++' token
   45 |               ans++;
      |                  ^~
a.cc:45:20: error: expected ']' before ';' token
   45 |               ans++;
      |                    ^
      |                    ]
a.cc: In lambda function:
a.cc:45:20: error: expected '{' before ';' token
a.cc: In function 'int main()':
a.cc:47:21: error: 'i' was not declared in this scope
   47 |             if (box[i+1][j+1] == '#'){
      |                     ^
a.cc:47:26: error: 'j' was not declared in this scope
   47 |             if (box[i+1][j+1] == '#'){
      |                          ^
a.cc:48:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
   48 |               ans++;
      |               ^~~
      |               abs
a.cc:50:19: error: 'ans' was not declared in this scope; did you mean 'abs'?
   50 |             cout<<ans;
      |                   ^~~
      |                   abs
a.cc: At global scope:
a.cc:53:9: error: 'cout' does not name a type
   53 |         cout << endl;
      |         ^~~~
a.cc:54:5: error: expected declaration before '}' token
   54 |     }
      |     ^
a.cc:56:5: error: expected unqualified-id before 'return'
   56 |     return 0;
      |     ^~~~~~
a.cc:57:1: error: expected declaration before '}' token
   57 | }
      | ^