title: Program wont compile
body: <p>Here is the code</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  class sudoku {
      public:
          void read(ifstream ifs);
          void write(ofstream ofs);
  
      private:
          int puzzle[9][9];
  
  };
  
  void sudoku::read(ifstream ifs){
      int row;
      int col;
      int value;
      int linenum = 1;
      bool error = false;
  
      while(ifs &gt;&gt; row){
          ifs &gt;&gt; col;
          ifs &gt;&gt; value;
  
          if(row &lt; 0 || row &gt; 8){
              cerr &lt;&lt; "Incorrect Row Value: " &lt;&lt; row &lt;&lt; " Line Number: " &lt;&lt; linenum;
              error = true;
          }
  
          if(col &lt; 0 || col &gt; 8){
              error = true;
              cerr &lt;&lt; "Incorrect Col Value: " &lt;&lt; col &lt;&lt; " Line Number: " &lt;&lt; linenum;
          }
  
          if(value &lt; 1 || value &gt; 9){
              error = true;
              cerr &lt;&lt; "Invalid Value: " &lt;&lt; value &lt;&lt; " Line Number: " &lt;&lt; linenum;
          }
  
          if (! error)
              puzzle[row][col] = value;
  
          error = false;
      }
  }
  
  void sudoku::write(ofstream ofs){
  
      for (int i = 0; i &lt; 9; i++){
          for (int j = 0; j &lt; 0; j++){
  
              if(puzzle[i][j] != 0){
                  ofs &lt;&lt; i &lt;&lt; ' ' &lt;&lt; j &lt;&lt; ' ' &lt;&lt; puzzle[i][j] &lt;&lt; endl;
              }
  
          }
  
      }
  
  }
  
  
  int main(int argc, char* argv[]){
  
      sudoku sudopuzzle;
  
      string filename = argv[1];
  
      int found = filename.find(".txt");
      if(found == filename.npos) {
          cout &lt;&lt; "No .txt extension" &lt;&lt; endl;
          return 0;
      }
  
  
      ifstream ifs;
      ifs.open(filename.c_str());
  
      sudopuzzle.read(ifs);
  
      ifs.close();
  
      filename.resize(filename.size()-4);
  
      filename.append("_checked.txt");
  
      ofstream ofs;
      ofs.open(filename.c_str());
  
      sudopuzzle.write(ofs);
      ofs.close();
  
      return 0;
  }
  </code></pre>
  
  <p>This program is supposed to read a generated puzzle. make sure its valid and write it to another file. Normally I am good at figuring out errors but this one is a mess. It spits out stuff referring to the inclusion of iostream and cites files that I have nothing to do with. Im guessing its some error that comes with passing fstreams to funcitons or something. any clue?</p>