Escape Sequences in C++

On UNIX new line in text files is LF (line feed character, ASCII 10).On DOS/Windows, the new line characters are CRLF (carriage return + line feed, ASCII 13, 10).
To write a new line in DOS/Windows, the exact sequence is “\r\n”. You might have noticed this in some programs.
However, to make DOS compatible with UNIX conventions, some functions internally translate “\n” to “\r\n”. For example, printf does this translation so you only need to say “hello\n” but the DOS-specific cprintf (this used to be in Borland C) does not perform this translation because this function is not available on UNIX so it expects DOS-specific codes, so you must use “hello\r\n” with this function, otherwise it would print lines with a stair-case effect:
 Like “Hello\nWorld” may appear as:
Hello
       World

Comments

Popular posts from this blog

Imote2 with Camera setup IMB400 over Ubuntu 9.10/10.04

Branch and bound algorithm in C#- Article by AsiF Munir

Tensorflow - Simplest Gradient Descent using GradientDescentOptimizer