title: How to debug the error "'fout' was not declared in this scope"
body: <p>I need to make the following:</p>
  
  <blockquote>
    <p>is considered a chessboard of size nxn they are willing obstacles. Required to print the minimum number of moves required to move a madman, respecting the rules of chess and avoiding obstacles, from an initial position to a final position on time. It is believed that the initial and final position of the fool there are no obstacles.</p>
  </blockquote>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;fstream&gt;
  using namespace std;
  #define INF 9999
  
  int a[100][100];
  int c[100][100];
  int ip, jp, is, js;
  int i,j;
  int m, n;
  const int di[] = { -1, 0, 1, 0 },
      dj[] = { 0, 1, 0, -1 };
  
  bool OK( int i, int j );
  void Lee();
  void Write();
  void Read();
  
  int main()
   {
      Read();
      Lee();
      Write();
  
      return 0;
       }
  
    void Read()
      {
      ifstream fin("lee.in");
      fin &gt;&gt; n &gt;&gt; m;
      fin &gt;&gt; ip &gt;&gt; jp &gt;&gt; is &gt;&gt; js;
      for ( int i = 0; i &lt; n; i++ )
              for ( int j = 0; j &lt; m; j++ )
              {
                      fin &gt;&gt; a[i][j];
                      c[i][j] = INF;
              }
      fin.close();
        }
  
        bool OK()
         {
        if ( a[i][j] == 1 ){ return false;} // obstacol, marcat de cifra 1 aici.
      if ( i &lt; 0 || j &lt; 0 || i &gt;= n || j &gt;= m ){}
              return false; // in afara matricei
      return true;  // niciuna din conditiile de mai sus nu au fost adevarate.
               }
  
      void Lee()
         {
      c[ip][jp] = 0; // punctul de plecare. distanta pana la el fiind de 0.
      bool modif;
      int pas = 0; // numarul de pasi efectuati.
      do
      {
              modif = false;
              for ( int i = 0; i &lt; n; i++ )
                              for ( int j = 0; j &lt; m; j++ )
                                      if ( c[i][j] == pas ) 
                                for ( int d = 0; d &lt; 4; ++d )
                                              {
  
                                                      int iv = i + di[d];
                                                      int jv = j + dj[d];
                                                      if ( OK( iv, jv) )
                                                      {
                    c[iv][jv] = pas + 1;
                                                              modif = true;
            if ( iv == is &amp;&amp; jv == js ) 
                                                                      return;
                                                      }
                                              }
                     pas++;
              } while ( modif );
                }
  
                  void Write()
                    {
      for ( int i = 0; i &lt; n; i++ )
      {
              for ( int j = 0; j &lt; m; j++ )
                              fout &lt;&lt; c[i][j] &lt;&lt; ' ';
              fout &lt;&lt; '\n';
      }
      fout &gt;&gt; c[is][js];
  
  
              }
  </code></pre>
  
  <p>I have 3 errors "'fout' was not declared in this scope", I don't know which is the cause.</p>