Language: C++

#include <iostream>
#include <string>
using namespace std;
long matrix[400][400] = {};
long count_matrix[400][400] = {};
int H, W, route_count = 0;

void black(int i, int j){
  matrix[i][j] = 10;
  if(i - 1 >= 0){
    if(matrix[i - 1][j] == -2) white(i-1, j);
  }
  if(i + 1 < H){
    if(matrix[i + 1][j] == -2) white(i+1, j);
  }
  if(j - 1 >= 0){
    if(matrix[i][j - 1] == -2) white(i, j-1);
  }
  if(j + 1 < W){
    if(matrix[i][j + 1] == -2) white(i, j+1);
  }
  matrix[i][j] = -1;
}

void white(int i, int j){
  count_matrix[i][j] = 1;
  matrix[i][j] = 10;
  if(i - 1 >= 0){
    if(matrix[i - 1][j] == -1) black(i-1, j);
  }
  if(i + 1 < H){
    if(matrix[i + 1][j] == -1) black(i+1, j);
  }
  if(j - 1 >= 0){
    if(matrix[i][j - 1] == -1) black(i, j-1);
  }
  if(j + 1 < W){
    if(matrix[i][j + 1] == -1) black(i, j+1);
  }
  matrix[i][j] = -2;
}

void reset_count_matrix(){  //count_matrixの値をすべてゼロにする(初期化)
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      count_matrix[i][j] = 0;
    }
  }
}

void counter(){  //countに組み合わせ数を加算する
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if(count_matrix[i][j] == 1){
        route_count++;
    }
  }
}

int main() {
  cin >> H >> W;
  string S[400] = {};
 
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S[i][j] == '#')matrix[i][j] = -1;
      else if (S[i][j] == '.')matrix[i][j] = -2;
      else matrix[i][j] = -100;
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if(matrix[i][j] == -1) {  //黒の場合だけカウントをスタートする
        reset_count_matrix();
        black(i, j);
        counter();
      }
    }
  }

  cout << route_count <<endl;
}

Compiler output:
a.cc: In function 'void black(int, int)':
a.cc:11:32: error: 'white' was not declared in this scope; did you mean 'fwrite'?
   11 |     if(matrix[i - 1][j] == -2) white(i-1, j);
      |                                ^~~~~
      |                                fwrite
a.cc:14:32: error: 'white' was not declared in this scope; did you mean 'fwrite'?
   14 |     if(matrix[i + 1][j] == -2) white(i+1, j);
      |                                ^~~~~
      |                                fwrite
a.cc:17:32: error: 'white' was not declared in this scope; did you mean 'fwrite'?
   17 |     if(matrix[i][j - 1] == -2) white(i, j-1);
      |                                ^~~~~
      |                                fwrite
a.cc:20:32: error: 'white' was not declared in this scope; did you mean 'fwrite'?
   20 |     if(matrix[i][j + 1] == -2) white(i, j+1);
      |                                ^~~~~
      |                                fwrite
a.cc: In function 'void counter()':
a.cc:60:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   60 | int main() {
      |         ^~
a.cc:60:9: note: remove parentheses to default-initialize a variable
   60 | int main() {
      |         ^~
      |         --
a.cc:60:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:60:12: error: a function-definition is not allowed here before '{' token
   60 | int main() {
      |            ^
a.cc:87:2: error: expected '}' at end of input
   87 | }
      |  ^
a.cc:51:15: note: to match this '{'
   51 | void counter(){  //countに組み合わせ数を加算する
      |               ^