Language: C++

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

int main(){
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    rep(i,h){
        rep(j,w){
            if(s[i][j] == '#'){
                cout << "#";
            }
            else{
                int cnt = 0;
                if(s[i-1)][j-1] == '#')cnt++;
                if(s[i-1)][j] == '#')cnt++;
                if(s[i-1][j+1)] == '#')cnt++;
                if(s[i][j-1] == '#')cnt++;
                if(s[i][j+1] == '#')cnt++;
                if(s[i+1][j-1] == '#')cnt++;
                if(s[i+1][j] == '#')cnt++;
                if(s[i+1][j+1] == '#')cnt++;
                cout << cnt;
            }
        }
        cout << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:20:25: error: expected ']' before ')' token
   20 |                 if(s[i-1)][j-1] == '#')cnt++;
      |                         ^
      |                         ]
a.cc:20:25: error: could not convert 's.std::vector<std::__cxx11::basic_string<char> >::operator[](((std::vector<std::__cxx11::basic_string<char> >::size_type)(i - 1)))' from '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} to 'bool'
   20 |                 if(s[i-1)][j-1] == '#')cnt++;
      |                         ^
      |                         |
      |                         __gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type {aka std::__cxx11::basic_string<char>}
a.cc:20:26: error: expected primary-expression before ']' token
   20 |                 if(s[i-1)][j-1] == '#')cnt++;
      |                          ^
a.cc:21:25: error: expected ']' before ')' token
   21 |                 if(s[i-1)][j] == '#')cnt++;
      |                         ^
      |                         ]
a.cc:21:25: error: could not convert 's.std::vector<std::__cxx11::basic_string<char> >::operator[](((std::vector<std::__cxx11::basic_string<char> >::size_type)(i - 1)))' from '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} to 'bool'
   21 |                 if(s[i-1)][j] == '#')cnt++;
      |                         ^
      |                         |
      |                         __gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type {aka std::__cxx11::basic_string<char>}
a.cc:21:26: error: expected primary-expression before ']' token
   21 |                 if(s[i-1)][j] == '#')cnt++;
      |                          ^
a.cc:22:30: error: expected ']' before ')' token
   22 |                 if(s[i-1][j+1)] == '#')cnt++;
      |                              ^
      |                              ]
a.cc:22:31: error: expected primary-expression before ']' token
   22 |                 if(s[i-1][j+1)] == '#')cnt++;
      |                               ^