Print new line to a text file without carriage return (CR) in windows

后端 未结 1 1244
天命终不由人
天命终不由人 2021-02-10 16:57

I am writing a program in C that prints a random hexadecimal value to a text file. The printed value has a carriage return (CR) along with a line feed (LF). However, the CR (vis

1条回答
  •  星月不相逢
    2021-02-10 17:36

    Open/create the file in binary mode

    file = fopen(tracefile, "wb");
                              ^ Binary mode
    

    Otherwise

    fprintf(file,"\n"); /* In text mode this appends two characters. */
    

    0 讨论(0)
提交回复
热议问题