In Windows, each line ends with "<line break> <press enter>", that is, "\ n \ r ";
In Unix systems, each line ends with only "<line feed>", that is, "\ n ";
In MAC systems, each line ends with "<press enter>", that is, "\ r ";
Source code:
# Include <stdio. h> # define cr0x0d // <press enter> '\ R' # define lf0x0a // <line feed>' \ n' # Define space 0x20 // <space> void dos2unix (char * file_name ); int main (void) {dos2unix ("aaa.txt"); Return 0 ;}// function of dos2unix is implemented in C language. For Windows, press enter to convert the line feed to udid press ENTER void dos2unix (char * file_name) {file * fp = NULL; FP = fopen (file_name, "RB +"); If (FP! = NULL) {char ch; while (fread (& Ch, sizeof (CH), 1, FP) = 1) {If (Cr = CH) {CH = space; fseek (FP,-1l, seek_cur); fwrite (& Ch, sizeof (CH), 1, FP); fseek (FP, 1l, seek_cur );}}} if (FP! = NULL) {fclose (FP); FP = NULL ;}}