Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  int H, W;
  cin >> H >> W;
  string S;
  int x=0;
  for(int i = 0; i < H; i++){
    cin >> S[i];
  }//Sの配置完了
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(S[i][j] == '.'){
        if((0<i-1<H-1)&&(0<j-1<w-1)){
          if(S[i-1][j-1]=='#'){
          x++;
          }
        }
        if((0<i-1<H-1)&&(0<j<w-1)){
          if(S[i-1][j]=='#'){
          x++;
          }
        }
        if((0<i-1<H-1)&&(0<j+1<w-1)){
          if(S[i-1][j+1]=='#'){
          x++;
          }
        }
        if((0<i<H-1)&&(0<j-1<w-1)){
          if(S[i][j-1]=='#'){
          x++;
          }
        }
        if((0<i<H-1)&&(0<j+1<w-1)){
          if(S[i][j+1]=='#'){
          x++;
          }
        }
        if((0<i+1<H-1)&&(0<j-1<w-1)){
          if(S[i+1][j-1]=='#'){
          x++;
          }
        }
          if((0<i+1<H-1)&&(0<j<w-1)){
            if(S[i+1][j]=='#'){
          x++;
            }
        }
          if((0<i+1<H-1)&&(0<j+1<w-1)){
            if(S[i+1][j+1]=='#'){
          x++;
            }
        }
        S[i][j]='x';
      }
    }
  }
  cout << S << endl;


Compiler output:
a.cc: In function 'int main()':
a.cc:14:14: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   14 |       if(S[i][j] == '.'){
      |              ^
a.cc:15:32: error: 'w' was not declared in this scope
   15 |         if((0<i-1<H-1)&&(0<j-1<w-1)){
      |                                ^
a.cc:16:20: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   16 |           if(S[i-1][j-1]=='#'){
      |                    ^
a.cc:20:30: error: 'w' was not declared in this scope
   20 |         if((0<i-1<H-1)&&(0<j<w-1)){
      |                              ^
a.cc:21:20: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   21 |           if(S[i-1][j]=='#'){
      |                    ^
a.cc:25:32: error: 'w' was not declared in this scope
   25 |         if((0<i-1<H-1)&&(0<j+1<w-1)){
      |                                ^
a.cc:26:20: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   26 |           if(S[i-1][j+1]=='#'){
      |                    ^
a.cc:30:30: error: 'w' was not declared in this scope
   30 |         if((0<i<H-1)&&(0<j-1<w-1)){
      |                              ^
a.cc:31:18: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   31 |           if(S[i][j-1]=='#'){
      |                  ^
a.cc:35:30: error: 'w' was not declared in this scope
   35 |         if((0<i<H-1)&&(0<j+1<w-1)){
      |                              ^
a.cc:36:18: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   36 |           if(S[i][j+1]=='#'){
      |                  ^
a.cc:40:32: error: 'w' was not declared in this scope
   40 |         if((0<i+1<H-1)&&(0<j-1<w-1)){
      |                                ^
a.cc:41:20: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   41 |           if(S[i+1][j-1]=='#'){
      |                    ^
a.cc:45:32: error: 'w' was not declared in this scope
   45 |           if((0<i+1<H-1)&&(0<j<w-1)){
      |                                ^
a.cc:46:22: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   46 |             if(S[i+1][j]=='#'){
      |                      ^
a.cc:50:34: error: 'w' was not declared in this scope
   50 |           if((0<i+1<H-1)&&(0<j+1<w-1)){
      |                                  ^
a.cc:51:22: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   51 |             if(S[i+1][j+1]=='#'){
      |                      ^
a.cc:55:13: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}[int]' for array subscript
   55 |         S[i][j]='x';
      |             ^
a.cc:59:21: error: expected '}' at end of input
   59 |   cout << S << endl;
      |                     ^
a.cc:4:11: note: to match this '{'
    4 | int main(){
      |           ^