I have a normal text file that lines end with normal \r\n. However, when using 'open' and 'read', Windows convert all the \r\n to \n. I know this means I have to open the file in binary mode but the function 'open' doesn't give this option, it has only read-only, write-only, or read-write.
This is the code:
int File_Size = ...;
char* Buffer = (char*)malloc(File_Size);
int Handle = open(File_Path,O_RDONLY);
read(Handle,Buffer,File_Size);
close(Handle);
Try using O_RDONLY|O_BINARY
.
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