From 5.2.2/2 (character display semantics) :
\b
(backspace) Moves the active position to the previous position on the current line. If the active position is at the initial position of a line, the behavior of the display device is unspecified.
\n
(new line) Moves the active position to the initial position of the next line.
\r
(carriage return) Moves the active position to the initial position of the current line.
Here, your code produces :
<new_line>ab
\b
: back one character- write
si
: overrides theb
withs
(producingasi
on the second line) \r
: back at the beginning of the current line- write
ha
: overrides the first two characters (producinghai
on the second line)
In the end, the output is :
\nhai