In short words, on mingw-gcc 4.9.0 the following code produces a text file with 
contents "a\r\nb\r\n", while replacing open() + fdopen() with a single fopen() 
produces "a\nb\n". Any ideas?

#include <stdio.h>
#include <fcntl.h>

int main ()
{
  int fd;
  FILE *pf;

  fd = open("alphabet.txt", O_WRONLY | O_CREAT | O_TRUNC);
  if (fd != -1) {
    pf = fdopen(fd, "wb");
        if (pf) {
      putc ( 'a' , pf );
      putc ( '\n' , pf );
      putc ( 'b' , pf );
      putc ( '\n' , pf );

          fclose(pf);
        }
    close(fd);
  }
}

Best regards.
2014-01-09
lh_mouse

------------------------------------------------------------------------------
CenturyLink Cloud: The Leader in Enterprise Cloud Services.
Learn Why More Businesses Are Choosing CenturyLink Cloud For
Critical Workloads, Development Environments & Everything In Between.
Get a Quote or Start a Free Trial Today. 
http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.clktrk
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to