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);
尝试使用O_RDONLY|O_BINARY
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.