As all we know in windows EOL is CRLF and in linux LF and CR in Mac. (more_info)
I want to write a program which reads as linux and Mac as well Win files line by line in Windows. To open file I would use fopen in "rt" mode, but I don't know how read lines. fgets reads until CRLF and LF under Windows but I want it to work for EOL=CR files also.
So what is the solution? Thanks in advance.
To open in "t" mode, the file must conform to the platform you are running on. Otherwise you just have to open in binary mode, and sort the difference out yourself.
The C library helps you write a program that works roughly the same on different platforms, but does not support "cross reading" the files.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With