Language: C++

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

int main() {
  int H, W;
  cin >> H >> W;
  
  string S0, S1;
  cin >> S0 >> S1;
    
  for (int j = 0; j < W; j++) {
    if (S0.at(j)=='.') {
      int count=0;
      char countre;
      if (S0.at(j-1)=='#')
        count++;
      if (S0.at(j+1)=='#')
        count++;
      if (S1.at(j-1)=='#')
        count++;
      if (S1.at(j)=='#')
        count++;
      if (S1.at(j+1)=='#')
        count++;
      countre = to_char(count);
      S0.at(j)=countre;
    }
  }
  cout << S0 << endl; //0行目終了
  
  string Sb, Sn, Sa;
  
  Sb=S0;
  Sn=S1;
  cin >> Sa; //2列目を入力
  
  for (int i = 0; i < H-3; i++) {
    for (int j = 0; j < W; j++) {
      if (Sn.at(j)=='.') {
        int count=0;
        char countre;
        if (Sb.at(j-1)=='#')
          count++;
        if (Sb.at(j)=='#')
          count++;
        if (Sb.at(j+1)=='#')
          count++;
        if (Sn.at(j-1)=='#')
          count++;
        if (Sn.at(j+1)=='#')
          count++;
        if (Sa.at(j-1)=='#')
          count++;
        if (Sa.at(j)=='#')
          count++;
        if (Sa.at(j+1)=='#')
          count++;
        countre = to_char(count);
        Sn.at(j)=countre;
      }
    }
    cout << Sn << endl;
    Sb=Sn;
    Sn=Sa;
    string S;
    cin >> S;
    Sa=S;
  }                                //H-2行まで終了
  
      for (int j = 0; j < W; j++) {
      if (Sn.at(j)=='.') {
        int count=0;
        char countre;
        if (Sb.at(j-1)=='#')
          count++;
        if (Sb.at(j)=='#')
          count++;
        if (Sb.at(j+1)=='#')
          count++;
        if (Sn.at(j-1)=='#')
          count++;
        if (Sn.at(j+1)=='#')
          count++;
        if (Sa.at(j-1)=='#')
          count++;
        if (Sa.at(j)=='#')
          count++;
        if (Sa.at(j+1)=='#')
          count++;
        countre = to_char(count);
        Sn.at(j)=countre;
      }
    }
    cout << Sn << endl;
    Sb=Sn;
    Sn=Sa;
  
  for (int j = 0; j < W; j++) {
    if (Sn.at(j)=='.') {
      int count=0;
      char countre;
      if (Sn.at(j-1)=='#')
        count++;
      if (Sn.at(j+1)=='#')
        count++;
      if (Sb.at(j-1)=='#')
        count++;
      if (Sb.at(j)=='#')
        count++;
      if (Sb.at(j+1)=='#')
        count++;
      countre = to_char(count);
      Sn.at(j)=countre;
    }
  }
  cout << Sn << endl; //H行目終了
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:17: error: 'to_char' was not declared in this scope; did you mean 'u_char'?
   27 |       countre = to_char(count);
      |                 ^~~~~~~
      |                 u_char
a.cc:60:19: error: 'to_char' was not declared in this scope; did you mean 'u_char'?
   60 |         countre = to_char(count);
      |                   ^~~~~~~
      |                   u_char
a.cc:92:19: error: 'to_char' was not declared in this scope; did you mean 'u_char'?
   92 |         countre = to_char(count);
      |                   ^~~~~~~
      |                   u_char
a.cc:114:17: error: 'to_char' was not declared in this scope; did you mean 'u_char'?
  114 |       countre = to_char(count);
      |                 ^~~~~~~
      |                 u_char