What’s the difference between \\n
(newline) and \\r
(carriage return)?
In particular, are there any practical differences between
Since nobody else mentioned it specifically (are they too young to know/remember?) - I suspect the use of \r\n
originated for typewriters and similar devices.
When you wanted a new line while using a multi-line-capable typewriter, there were two physical actions it had to perform: slide the carriage back to the beginning (left, in US) of the page, and feed the paper up one notch.
Back in the days of line printers the only way to do bold text, for example, was to do a carriage return WITHOUT a newline and print the same characters over the old ones, thus adding more ink, thus making it appear darker (bolded). When the mechanical "newline" function failed in a typewriter, this was the annoying result: you could type over the previous line of text if you weren't paying attention.