[Master Answer Logo]
Question

C programming newline in a binary file?

Answer

The File Transfer Protocol can automatically convert newlines in files being transferred between systems with different newline representations when the transfer is done in ASCII mode. However, transferring binary files in this mode usually has disastrous results: Any occurrence of the newline byte sequence—which does not have line terminator semantics in this context, but is just a normal sequence of bytes—will be translated to whatever newline representation the other system uses, effectively corrupting the file. FTP clients often employ some heuristics (for example inspection of filename extensions) to automatically select either binary or ASCII mode, but in the end it is up to the user to make sure his files are transferred in the correct mode. If there is any doubt as to the correct mode, binary mode should be used, as then no files will be altered by FTP, though they may display incorrectly.

— Source: Wikipedia (www.wikipedia.org)