How to overwrite stdout in C

后端 未结 8 943
清歌不尽
清歌不尽 2020-12-07 18:13

In most modern shells, you can hit the up and down arrows and it will put, at the prompt, previous commands that you have executed. My question is, how does this work?!

8条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-07 18:26

    The simplest way is to print to stdout the carriage return character ('\r').

    The cursor will be moved to the start of the line, allowing you to overwrite its contents.

提交回复
热议问题