Language: C++

int main(void) {
  int h, w;
  cin >> h >> w; //高さ広さ
  
  string board[50]; 

  for (int i = 0; i < h; ++i) cin >> board[i]; //横一列の.と#が文字列として入る
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1}; //dx,dyで8通りの隣接関係を表現
  const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (board[i][j] == ’#’) continue; //board[i]の[j]文字目が#ならこのfor()を飛ばす
      int num = 0;
      for (int d = 0; d < 8; ++ d) {
        const int ni = i + dy[d];　//(i,j)と隣り合った(ni,nj)が8通り。
        const int nj = j + dx[d];
        if (ni < 0 or h <= ni) continue; //niが負とかhより大きいとかは存在しないので飛ばす
        if (nj < 0 or w <= nj) continue;
        if (board[ni][nj] == ’#’) num++; //周囲に爆弾があったらnum++
      }
      board[i][j] = char(num + ’0’); //数値を文字列にするときは+'0'するASCIIコードの都合で。
    }
  }
  for (int i = 0; i < h; ++i) cout << board[i] << endl;
  return 0;
}


Compiler output:
a.cc:13:26: error: extended character ’ is not valid in an identifier
   13 |       if (board[i][j] == ’#’) continue; //board[i]の[j]文字目が#ならこのfor()を飛ばす
      |                          ^
a.cc:13:27: error: stray '#' in program
   13 |       if (board[i][j] == ’#’) continue; //board[i]の[j]文字目が#ならこのfor()を飛ばす
      |                           ^
a.cc:13:28: error: extended character ’ is not valid in an identifier
   13 |       if (board[i][j] == ’#’) continue; //board[i]の[j]文字目が#ならこのfor()を飛ばす
      |                            ^
a.cc:16:34: error: extended character 　 is not valid in an identifier
   16 |         const int ni = i + dy[d];　//(i,j)と隣り合った(ni,nj)が8通り。
      |                                  ^
a.cc:20:30: error: extended character ’ is not valid in an identifier
   20 |         if (board[ni][nj] == ’#’) num++; //周囲に爆弾があったらnum++
      |                              ^
a.cc:20:31: error: stray '#' in program
   20 |         if (board[ni][nj] == ’#’) num++; //周囲に爆弾があったらnum++
      |                               ^
a.cc:20:32: error: extended character ’ is not valid in an identifier
   20 |         if (board[ni][nj] == ’#’) num++; //周囲に爆弾があったらnum++
      |                                ^
a.cc:22:32: error: extended character ’ is not valid in an identifier
   22 |       board[i][j] = char(num + ’0’); //数値を文字列にするときは+'0'するASCIIコードの都合で。
      |                                ^
a.cc:22:32: error: extended character ’ is not valid in an identifier
a.cc: In function 'int main()':
a.cc:3:3: error: 'cin' was not declared in this scope
    3 |   cin >> h >> w; //高さ広さ
      |   ^~~
a.cc:5:3: error: 'string' was not declared in this scope
    5 |   string board[50];
      |   ^~~~~~
a.cc:7:38: error: 'board' was not declared in this scope
    7 |   for (int i = 0; i < h; ++i) cin >> board[i]; //横一列の.と#が文字列として入る
      |                                      ^~~~~
a.cc:13:11: error: 'board' was not declared in this scope
   13 |       if (board[i][j] == ’#’) continue; //board[i]の[j]文字目が#ならこのfor()を飛ばす
      |           ^~~~~
a.cc:13:26: error: '\U00002019' was not declared in this scope
   13 |       if (board[i][j] == ’#’) continue; //board[i]の[j]文字目が#ならこのfor()を飛ばす
      |                          ^
a.cc:13:27: error: expected ')' before '\U00002019'
   13 |       if (board[i][j] == ’#’) continue; //board[i]の[j]文字目が#ならこのfor()を飛ばす
      |          ~                ^~
      |                           )
a.cc:16:34: error: '\U00003000' was not declared in this scope
   16 |         const int ni = i + dy[d];　//(i,j)と隣り合った(ni,nj)が8通り。
      |                                  ^~
a.cc:19:13: error: 'nj' was not declared in this scope; did you mean 'ni'?
   19 |         if (nj < 0 or w <= nj) continue;
      |             ^~
      |             ni
a.cc:20:13: error: 'board' was not declared in this scope
   20 |         if (board[ni][nj] == ’#’) num++; //周囲に爆弾があったらnum++
      |             ^~~~~
a.cc:20:23: error: 'nj' was not declared in this scope; did you mean 'ni'?
   20 |         if (board[ni][nj] == ’#’) num++; //周囲に爆弾があったらnum++
      |                       ^~
      |                       ni
a.cc:20:30: error: '\U00002019' was not declared in this scope
   20 |         if (board[ni][nj] == ’#’) num++; //周囲に爆弾があったらnum++
      |                              ^
a.cc:20:31: error: expected ')' before '\U00002019'
   20 |         if (board[ni][nj] == ’#’) num++; //周囲に爆弾があったらnum++
      |            ~                  ^~
      |                               )
a.cc:22:7: error: 'board' was not declared in this scope
   22 |       board[i][j] = char(num + ’0’); //数値を文字列にするときは+'0'するASCIIコードの都合で。
      |       ^~~~~
a.cc:22:32: error: '\U000020190\U00002019' was not declared in this scope
   22 |       board[i][j] = char(num + ’0’); //数値を文字列にするときは+'0'するASCIIコードの都合で。
      |                                ^~~
a.cc:25:31: error: 'cout' was not declared in this scope
   25 |   for (int i = 0; i < h; ++i) cout << board[i] << endl;
      |                               ^~~~
a.cc:25:39: error: 'board' was not declared in this scope
   25 |   for (int i = 0; i < h; ++i) cout << board[i] << endl;
      |                                       ^~~~~
a.cc:25:51: error: 'endl' was not declared in this scope
   25 |   for (int i = 0; i < h; ++i) cout << board[i] << endl;
      |                                                   ^~~~