title: Trouble with file input [C++]
body: <p>I was trying for the first time to read data from a file, a .txt file. Below is my code:</p>
  
  <pre><code>Level::ReadStream(std::fstream data)
  {
  bool write = false;
  char* p = data.tellg();
  
  while(!data.eof())
  {
      int i = 0, j = 0;
  
      if(&amp;p == '[')
      {
          write == true;
      }
  
      if(write == true)
      {
          mapX[i] = p;
          mapY[j] = p;
      }
  
      if(&amp;p == '/n')
      {
          i++;
          j++;
      }
  
      else
      {
          i++;
      }
  
      *p++
  }
  };
  
  void Level::SetMapSize(std::fstream data)
  {
  int* p = data.tellg();
  int sizeX = 0;
  int sizeY = 0;
  
  while(!data.eof())
  {
      if(&amp;p != '[' &amp;&amp; &amp;p != ']' &amp;&amp; &amp;p != '\n')
      {
          sizeX++;
      }
  
      else if(&amp;p != '\n')
      {
          sizeY++;
      }
  }
  
  mapX.resize(sizeX);
  mapY.resize(sizeY);
  
  std::cout &lt;&lt; sizeX &lt;&lt; '\n' &lt;&lt; sizeY;
  };
  </code></pre>
  
  <p>The goal of these two functions are to:
  1- read all the chars in the file and, if the current character is not a bracket, add it to an index map(X, Y), then increase the counter so the next non-bracket value will be put in the correct index.</p>
  
  <p>2- read all the file and, as before, count the non-bracket values, so it can make mapX and mapY the correct size.</p>
  
  <p>However, it's not working, and I got these errors:</p>
  
  <pre><code> C:\...\Level.cpp|58|warning: multi-character character constant|
  
   c:\...\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\bits\ios_base.h|790|error: 'std::ios_base::ios_base(const std::ios_base&amp;)' is private|
  
   c:\...\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|47|error: within this context|
  
   c:...\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|87|note: synthesized method 'std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;::basic_ios(const std::basic_ios&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)' first required here |
  
   c:...\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\streambuf|770|error: 'std::basic_streambuf&lt;_CharT, _Traits&gt;::basic_streambuf(const std::basic_streambuf&lt;_CharT, _Traits&gt;&amp;) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;]' is private|
  
   c:...\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|78|error: within this context|
  
   c:...\mingw\bin\..\lib\gcc\mingw32\4.4.1\include\c++\iosfwd|87|note: synthesized method 'std::basic_filebuf&lt;char, std::char_traits&lt;char&gt; &gt;::basic_filebuf(const std::basic_filebuf&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)' first required here |
  
  C:...\Level.cpp||In constructor 'Level::Level()':|
  
  C:...\Level.cpp|24|note: synthesized method 'std::basic_fstream&lt;char, std::char_traits&lt;char&gt; &gt;::basic_fstream(const std::basic_fstream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;)' first required here |
  
  C:...\Level.cpp|24|error:   initializing argument 1 of 'void Level::SetMapSize(std::fstream)'|
  
  C:...\Level.cpp|29|error: 'cout' was not declared in this scope|
  
  C:...\Level.cpp|38|error: ISO C++ forbids declaration of 'ReadStream' with no type|
  
  C:...\Level.cpp|38|error: prototype for 'int Level::ReadStream(std::fstream)' does not match any in class 'Level'|
  
  C :...\Level.cpp|17|error: candidate is: void Level::ReadStream(std::fstream)|
  C:...\Level.cpp||In member function 'void Level::SetMapSize(std::fstream)':|
  C:...\Level.cpp|75|error: invalid conversion from 'std::streamoff' to 'int*'|
  C:...\Level.cpp|81|error: ISO C++ forbids comparison between pointer and integer|
  C:...\Level.cpp|81|error: ISO C++ forbids comparison between pointer and integer|
  C:...\Level.cpp|81|error: ISO C++ forbids comparison between pointer and integer|
  C:...\Level.cpp|86|error: ISO C++ forbids comparison between pointer and integer|
  C:...\Level.cpp|95|error: 'cout' is not a member of 'std'|
  ||=== Build finished: 15 errors, 1 warnings ===|
  </code></pre>
  
  <p>Can anyone help?</p>
  
  <p>EDIT: Ok, I changed everything. My new code is:</p>
  
  <pre><code>void Level::ReadStream()
  {
  long p = textData.tellg();
  int counter = 0;
  int i = 0;
  int j = 0;
  char ch;
  
  while(p != textData.eof())
  {
      textData.seekg(counter);
      textData &gt;&gt; ch;
  
      if(ch != '[' &amp;&amp; ch != ']')
      {
          mapX[i] = ch;
          mapY[j] = ch;
  
          i++;
  
          if(ch == '\n')
          {
              i = 0;
              j++;
          }
      }
  
      counter++;
      p = textData.tellg();
  }
  };
  </code></pre>
  
  <p>with mapX and mapY being 5 int long. Now it compiles, but hangs and crashes. I don't see why... Is there anyone that can help me?</p>