Because you are writing everything on the same line after the first \n
:
printf( "\nab" ); // -> ab on a new line
Line status : ab
printf( "\bsi" );
It means ab
minus the b
because of the backspace then you add si
to the line.
Line status : asi
Finally :
printf( "\rha" );
Means that you go back at the beginning of the line and write ha
.
It leads to hai
.
\r
is carriage-return, not linefeed.