title: Having problems with 0x0A character in C++ even in binary mode. (interprets it as new file)
body: <p>Hi this might seem a bit noobie, but here we go. Im developing a program that downloads leaderboards of a certain game from the internet and transforms it into a proper format to work with it (elaborate rankings, etc).</p>
  
  <p>The files contains the names, ordered by rank, but between each name there are 7 random <strong>control codes</strong> (obivously unprintable). The txt file looks like this:</p>
  
  <p>..C...hName1..)...&amp;Name2......)Name3..é...þName4..Ü...†Name5..‘...QName6..~...bName7..H...NName8..|....Name9..v...HName10.</p>
  
  <p>Checked via an hexEditor and saw the first control code after each name is always a null character (<strong>0x00</strong>). So, what I do is read everything, and then cout every character. When a 0x00 character is found, skip <strong>7</strong> characters and keep couting. Therefore you end up with the list, right?</p>
  
  <p>At first I had the problem that on those random control codes, sometimes you would find like a "soft EOF" (<strong>0x1A</strong>), and the program would stop reading there. So I finally figured out to open it in <strong>binary mode</strong>. It worked, and then everything would be couted... or thats what I thought.</p>
  
  <p>But I came across another file which still didn't work, and finally found out that there was an <strong>EOF</strong> character! (<strong>0x0A</strong>) Which doesn't makes sense since Im opening it in binary mode. But still, after reading that character, C++ interprets that as a new file, and hence skips 7 characters, so the name after that character will always appear cut.</p>
  
  <p>Here's my current code:
      </p>
  
  <pre><code>#include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  
  int main () {
    string scores;
    system("wget http://certainwebsite/001.txt"); //download file
    ifstream highin ("001.txt", ios::binary);
    ofstream highout ("board.txt", ios::binary);
    if (highin.is_open())
    {
      while ( highin.good() )
      {
            getline (highin, scores);
            for (int i=0;i&lt;scores.length(); i++)
            {
                if (scores[i]==0x00){
                   i=i+7; //skip 7 characters if 'null' is found
                   cout &lt;&lt; endl;
                   highout &lt;&lt; endl;
                   }
                cout &lt;&lt; scores[i];
                highout &lt;&lt; scores[i]; //cout names and save them in output file
            }
      }
      highin.close();
    }
    else cout &lt;&lt; "Unable to open file";
    system("pause&gt;nul");
  }
  </code></pre>
  
  <p>Not sure how to ignore that character if being already in binary mode doesn't work. Sorry for the long question but I wanted to be detailed and specific. In this case, the EOF character is located before the Name3, and hence this is how the output looks like:
  <a href="http://i.imgur.com/yu1NjoZ.png" rel="nofollow">http://i.imgur.com/yu1NjoZ.png</a></p>