title: converting new line character
body: <p>I am trying to convert new line character  \n to dos style which is \r\n , without using libc.</p>
  
  <p>here is my attempt, what am I doing wrong?</p>
  
  <pre><code>       for(i = 0; str[i]!='\0'; ++i)
  {
     if ('\r' == str[i] &amp;&amp; '\n'==str[i+1]) 
         ++count;
  }
  
  strPtr = malloc(i + 1 + count);
  
  for(i = j = 0; str[i]!='\0'; ++i)
  {
     if ('\r' == str[i]) 
     strPtr[j++] = "";
  }
  
  strPtr[j] = 0;
  </code></pre>
  
  <p>output should now be
  "Hi\r\n, How are you \r\n, are you okay\r\n"</p>