title: Remove Carriage Returns from char* (C++)
body: <p>I have defined a resource file in my Visual Studio 2008 C++ project. The problem is that after obtaining the resource data with LockResource method the resulting char buffer contains Carriage Returns and Line Feeds where as the original data contained only Line feeds. For instance if the original line contains:</p>
  
  <p>00 0A FC 80 00 00 27 10 00 0A FC 80 00 00 27 10</p>
  
  <p>The resulting char* contains also Carriage Returns (0D):</p>
  
  <p>00 0D 0A FC 80 00 00 27 10 00 0D 0A FC 80 00 00</p>
  
  <p>I tried the following code to get rid of them but this results in both carriage return and line feed to be removed:</p>
  
  <pre><code>for (int i = 0; i &lt; sz; ++i)
  {
      // Ignore carriage returns
      if (data[i] == '\n') continue;
      // ...
  }
  </code></pre>
  
  <p>How do I get rid of Carriage Returns but leave New Line characters?</p>
  
  <p>EDIT:</p>
  
  <p>To make it more specific. I am writing the char buffer into the file:</p>
  
  <pre><code>std::ofstream outputFile(fileName.c_str());
  
  for (int i = 0; i &lt; sz; ++i)
  {
      // Ignore carriage returns
      // if (data[i] == '\r') continue; This leaves both CR and LF 
      // if (data[i] == 0x0D) continue; This leaves both CR and LF
      if (data[i]) == '\n') continue; //This removes both CR and LF
      outputFile &lt;&lt; data[i];
  }
  </code></pre>