How do I erase printed characters in a console application(Linux)?

前端 未结 6 1601
慢半拍i
慢半拍i 2020-12-14 19:54

I am creating a small console app that needs a progress bar. Something like...

Conversion: 175/348 Seconds   |==========          |  50%

My

6条回答
  •  無奈伤痛
    2020-12-14 20:35

    I don't think you need to apologize for the language choice. PHP is a great language for console applications.

    Try this out:

    
    

    The "\r" will overwrite the line with the new text. To make a new line you can just use "\n", but I'm guessing you already knew that.

    Hope this helps! I know this works in Linux, but I don't know if it works in Windows or other operating systems.

提交回复
热议问题