title: carriage return by fgets
body: <p>I am running the following code:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;string.h&gt;
  #include&lt;io.h&gt;
  
  int main(){
      FILE *fp;
      if((fp=fopen("test.txt","r"))==NULL){
          printf("File can't be read\n");
          exit(1);
      }
      char str[50];
      fgets(str,50,fp);
      printf("%s",str);
      return 0;
  }
  </code></pre>
  
  <p>text.txt contains: <code>I am a boy\r\n</code></p>
  
  <p>Since I am on Windows, it takes \r\n as a new line character and so if I read this from a file it should store <code>"I am a boy\n\0"</code> in <code>str</code>, but I get <code>"I am a boy\r\n"</code>. I am using mingw compiler.</p>