How to update a printed message in terminal without reprinting

后端 未结 8 2102
时光取名叫无心
时光取名叫无心 2020-11-29 02:50

I want to make a progress bar for my terminal application that would work something like:

 [XXXXXXX       ] 

which would give a visual indi

相关标签:
8条回答
  • 2020-11-29 03:27

    It's a different language, but this question might be of assistance to you. Basically, the escape character \r (carriage Return, as opposed to \n Newline) moves you back to the beginning of your current printed line so you can overwrite what you've already printed.

    0 讨论(0)
  • 2020-11-29 03:35

    '\r' will perform a carriage return. Imagine a printer doing a carriage return without a linefeed ('\n'). This will return the writing point back to the start of the line... then reprint your updated status on top of the original line.

    0 讨论(0)
提交回复
热议问题