title: Reading from file, strange ending
body: <p>I've found a snippet of code that gives the size of a text file:</p>
  
  <pre><code>ifstream file("xmlfile.xml",ios::in);
  //get size
  file.seekg (0, ios::end);
  int length = file.tellg();
  file.seekg (0, ios::beg);
  
  // allocate memory:
  char* buffer = new char [length];
  
  // read data as a block:
  file.read (buffer,length);
  file.close();
  buffer[length-1] = '\0';
  printf("%s",buffer);
  </code></pre>
  
  <p>the thing is that with a small xml file that i would like to read, reads it perfectly, but leaves many '=' signs at the end, as i found out they equal to the number of CR's in the file. Switching the EOL to Unix solved the problem, but why is there a problem with printing in the Windows EOLs?</p>
  
  <p>Sample xml:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;catalog&gt;
  
  
  
  
  (EOL)
  </code></pre>
  
  <p>And what the printf prints:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;catalog&gt;
  
  
  
  
  
  ══════
  </code></pre>