Language: C++

#include <bits/stdc++.h>

int main () {
  
  using std::cin;
  
  using std::cout;
  
  int H, W;
  
  cin >> H >> W;
  
  vector <vector <char>> a (H, vector <char> (W));
  
  vector <int> h(H);
  vector <int> w(W);
  
  for (int i = 0; i < H; i++) {
    
    for (int j = 0; j < W; j++) {
      
      cin >> a.at(i).at(j);
      
      if (a.at(i).at(j) == '.'){
        
        h.at(i)++;
        
        w.at(j)++;
        
      }
      
    }
    
  }
  
  for (int i = 0; i < H; i++) {
    
    for (int j = 0; j < W; j++) {
      
      if (h.at(i) == H) {
        
        for (k = 0; k < H; k++){
          
          a.at(i).at(k) = '-';
          
        }
        
      }
      
      if (w.at(j) == W) {
        
        for (k = 0; k < W; k++){
          
          a.at(k).at(j) = '-';
          
        }
        
      }
      
    }
    
  }
  
  for (int i = 0; i < H; i++){
    
    for (int j = 0; j < W; j++){
      
      if (a.at(i).at(j) != '-') cout << a.at(i).at(j);
      
    }
    
    cout << endl;
    
  }
  
}

Compiler output:
a.cc: In function 'int main()':
a.cc:13:3: error: 'vector' was not declared in this scope
   13 |   vector <vector <char>> a (H, vector <char> (W));
      |   ^~~~~~
a.cc:13:3: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/14/vector:93:13: note:   'std::pmr::vector'
   93 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
a.cc:13:19: error: expected primary-expression before 'char'
   13 |   vector <vector <char>> a (H, vector <char> (W));
      |                   ^~~~
a.cc:15:11: error: expected primary-expression before 'int'
   15 |   vector <int> h(H);
      |           ^~~
a.cc:16:11: error: expected primary-expression before 'int'
   16 |   vector <int> w(W);
      |           ^~~
a.cc:22:14: error: 'a' was not declared in this scope
   22 |       cin >> a.at(i).at(j);
      |              ^
a.cc:26:9: error: 'h' was not declared in this scope
   26 |         h.at(i)++;
      |         ^
a.cc:28:9: error: 'w' was not declared in this scope
   28 |         w.at(j)++;
      |         ^
a.cc:40:11: error: 'h' was not declared in this scope
   40 |       if (h.at(i) == H) {
      |           ^
a.cc:42:14: error: 'k' was not declared in this scope
   42 |         for (k = 0; k < H; k++){
      |              ^
a.cc:44:11: error: 'a' was not declared in this scope
   44 |           a.at(i).at(k) = '-';
      |           ^
a.cc:50:11: error: 'w' was not declared in this scope
   50 |       if (w.at(j) == W) {
      |           ^
a.cc:52:14: error: 'k' was not declared in this scope
   52 |         for (k = 0; k < W; k++){
      |              ^
a.cc:54:11: error: 'a' was not declared in this scope
   54 |           a.at(k).at(j) = '-';
      |           ^
a.cc:68:11: error: 'a' was not declared in this scope
   68 |       if (a.at(i).at(j) != '-') cout << a.at(i).at(j);
      |           ^
a.cc:72:13: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   72 |     cout << endl;
      |             ^~~~
      |             std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~