简体   繁体   中英

How can I output erasable text in c++ to console?

I remember seeing completed programs where you could backspace and delete text prompts. Usually, all text that is cout'ed is static and cannot be erased from the screen, but I want to be able to erase text that was output by the program (such as, for example, the program gives me a default name that I can accept, or delete and enter my own). I would imagine I could fake keyboard input to put up erasable text on the console, but is there a cleaner way to do it? Thanks.

If I understand you, you probably want something like GNU Readline

"The GNU Readline library provides a set of functions for use by applications that allow users to edit command lines as they are typed in. Both Emacs and vi editing modes are available. The Readline library includes additional functions to maintain a list of previously-entered command lines, to recall and perhaps reedit those lines, and perform csh-like history expansion on previous commands."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM