( uid_2716 | 2012. 05. 13., v – 15:11 )

Egyébként sosem értettem, miért olyan fontos a \n?

A történelmi okot nem tudom megadni.

Az ISO C99 7.19.2 p2 szerint A text stream is an ordered sequence of characters composed into lines, each line consisting of zero or more characters plus a terminating new-line character. Whether the last line requires a terminating new-line character is implementation-defined. [...]

A SUSv4 ugyanakkor szigorúbb:

Line: A sequence of zero or more non-<newline> characters plus a terminating <newline> character.

Incomplete Line: A sequence of one or more non-<newline> characters at the end of the file.

Text File: A file that contains characters organized into zero or more lines. The lines do not contain NUL characters and none can exceed {LINE_MAX} bytes in length, including the <newline> character. Although POSIX.1-2008 does not distinguish between text files and binary files (see the ISO C standard), many utilities only produce predictable or meaningful output when operating on text files. The standard utilities that have such restrictions always specify "text files" in their STDIN or INPUT FILES sections.

A Rationale ezt mondja: [...] The only difference between text and binary files is that text files have lines of less than {LINE_MAX} bytes, with no NUL characters, each terminated by a <newline>. The definition allows a file with a single <newline>, or a totally empty file, to be called a text file. If a file ends with an incomplete line it is not strictly a text file by this definition. [...]

A LINE_MAX-ról bővebben itt.