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};
	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;

			int num = 0;
			for (int d = 0; d < 8; ++ d) {
				const int ni = i + dy[d];
				const int nj = j + dx[d];

				if (ni < 0 or h <= ni) continue;
				if (nj < 0 or w <= nj) continue;
				if (board[ni][nj] == ’#’) num++;
			}

			board[i][j] = char(num + ’0’);

		}
	}

	for (int i = 0; i < h; ++i) cout << board[i] << endl;

	return 0;
}

Compiler output:
a.cc:14:44: error: extended character ’ is not valid in an identifier
   14 |                         if (board[i][j] == ’#’) continue;
      |                                            ^
a.cc:14:45: error: stray '#' in program
   14 |                         if (board[i][j] == ’#’) continue;
      |                                             ^
a.cc:14:46: error: extended character ’ is not valid in an identifier
   14 |                         if (board[i][j] == ’#’) continue;
      |                                              ^
a.cc:23:54: error: extended character ’ is not valid in an identifier
   23 |                                 if (board[ni][nj] == ’#’) num++;
      |                                                      ^
a.cc:23:55: error: stray '#' in program
   23 |                                 if (board[ni][nj] == ’#’) num++;
      |                                                       ^
a.cc:23:56: error: extended character ’ is not valid in an identifier
   23 |                                 if (board[ni][nj] == ’#’) num++;
      |                                                        ^
a.cc:26:50: error: extended character ’ is not valid in an identifier
   26 |                         board[i][j] = char(num + ’0’);
      |                                                  ^
a.cc:26:50: error: extended character ’ is not valid in an identifier
a.cc: In function 'int main()':
a.cc:3:9: error: 'cin' was not declared in this scope
    3 |         cin >> h >> w;
      |         ^~~
a.cc:5:9: error: 'string' was not declared in this scope
    5 |         string board[50];
      |         ^~~~~~
a.cc:7:44: error: 'board' was not declared in this scope
    7 |         for (int i = 0; i < h; ++i) cin >> board[i];
      |                                            ^~~~~
a.cc:14:29: error: 'board' was not declared in this scope
   14 |                         if (board[i][j] == ’#’) continue;
      |                             ^~~~~
a.cc:14:44: error: '\U00002019' was not declared in this scope
   14 |                         if (board[i][j] == ’#’) continue;
      |                                            ^
a.cc:14:45: error: expected ')' before '\U00002019'
   14 |                         if (board[i][j] == ’#’) continue;
      |                            ~                ^~
      |                                             )
a.cc:23:37: error: 'board' was not declared in this scope
   23 |                                 if (board[ni][nj] == ’#’) num++;
      |                                     ^~~~~
a.cc:23:54: error: '\U00002019' was not declared in this scope
   23 |                                 if (board[ni][nj] == ’#’) num++;
      |                                                      ^
a.cc:23:55: error: expected ')' before '\U00002019'
   23 |                                 if (board[ni][nj] == ’#’) num++;
      |                                    ~                  ^~
      |                                                       )
a.cc:26:25: error: 'board' was not declared in this scope
   26 |                         board[i][j] = char(num + ’0’);
      |                         ^~~~~
a.cc:26:50: error: '\U000020190\U00002019' was not declared in this scope
   26 |                         board[i][j] = char(num + ’0’);
      |                                                  ^~~
a.cc:31:37: error: 'cout' was not declared in this scope
   31 |         for (int i = 0; i < h; ++i) cout << board[i] << endl;
      |                                     ^~~~
a.cc:31:45: error: 'board' was not declared in this scope
   31 |         for (int i = 0; i < h; ++i) cout << board[i] << endl;
      |                                             ^~~~~
a.cc:31:57: error: 'endl' was not declared in this scope
   31 |         for (int i = 0; i < h; ++i) cout << board[i] << endl;
      |                                                         ^~~~