and
are rarely used in practice. I just found out that I misunderstood these two escape sequences. A simple test:
printf("foobar
");
I expected it to output fobar
, because
will backspace the cursor, and b
will overwrite the second o
, but instead it outputs: foobar
The same is with
:
printf("foo
bar
");
I thought
will move the cursor to the beginning of the current line, so bar
will replace foo
, so the final output should be bar
. However, it actually outputs:
foo
bar
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…