0

This sentence from k&r:

A text stream consists of a sequence of lines; each line ends with a newline character....For instance, the library might convert carriage return and linefeed to newline on input and back again on ouput.

How can you convert linefeed to newline and why is it done?

6
  • 3
    I think it says "carriage return and linefeed" to newline -> \r\n = \n. Commented Jun 25, 2016 at 17:34
  • 1
    have you bothered to google for newline? Commented Jun 25, 2016 at 17:34
  • The [ wiki article ] says This is why a newline in character encoding can be defined as LF and CR combined into one Commented Jun 25, 2016 at 17:38
  • 2
    Carriage return and line-feed are both terms which originated with the typewriter. Some systems continued the idiom over, while others said it was nonsense to continue to use a carriage return, when clearly, a new-line character was enough to signal that the cursor should return to the start of the next line. The conversion is needed to make both types of system play nicely together. It's done by simply adding or removing a \r character. Commented Jun 25, 2016 at 17:39
  • 1
    This [ answer ] has got all the information you need. Commented Jun 25, 2016 at 17:49

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.