我记得看到完成的程序,您可以在其中退格并删除文本提示。通常,所有被 cout'ed 的文本都是静态的,不能从屏幕上删除,但我希望能够删除程序输出的文本(例如,程序给我一个默认名称,我可以接受,或删除并输入我自己的)。我想我可以伪造键盘输入以在控制台上放置可删除的文本,但是有没有更简洁的方法来做到这一点?谢谢。
最佳答案
如果我理解你,你可能想要类似 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."
关于c++ - 如何将 C++ 中的可删除文本输出到控制台?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4665808/