File IO, Handling CRLF

Posted by aCuria on Stack Overflow See other posts from Stack Overflow or by aCuria
Published on 2010-05-27T14:50:10Z Indexed on 2010/05/27 14:51 UTC
Read the original article Hit count: 275

Filed under:
|
|

Hi, i am writing a program that takes a file and splits it up into multiple small files of a user specified size, then join the multiple small files back again.

1) the code must work for c, c++

2) i am compiling with multiple compilers.

I am reading and writing to the files by using the stl functions fread() and fwrite()

The problem I am having pertains to CRLF. If the file I am reading from contains CRLF, then I want to retain it when i split and join the files back together. If the file contains LF, then i want to retain LF.

Unfortunately, fread() seems to store CRLF as \n (I think), and whatever is written by fwrite() is compiler-dependent.

How do i approach this problem?

Thanks.

© Stack Overflow or respective owner

Related posts about c++

Related posts about c