我如何在c + +控制台写文本,而不打破线 [英] How can i write text in c++ console without breaking the lines

查看:183
本文介绍了我如何在c + +控制台写文本,而不打破线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在c + +控制台中输入文本,而不会一次打断一行输入?
如果我使用cin我可以输入一个字符串每次加我无法编辑输入(除非我编辑字符串,但这不帮助)
有任何方法来输入字符串(多行),但



我正在运行ubuntu 12.04

解决方案

谁在写?是你还是一些程序?



你的术语是不寻常的:一般程序员都是计算机的观点! >

您在键盘上输入的内容是对某个程序的输入)。



如果你想要一个可编辑的输入(对程序,所以书写或由人类用户键入),请考虑使用 GNU readline (在Linux上),或者 ncurses



如果你想格式化程序的输出(用户用他的眼睛读)一般需要明确地对该格式化进行编码。也许 ANSI转义代码可能有用(但使用它们可能会使 readline ncurses 不愉快)。



另请参阅这个答案和我给的参考。


how can i input text in c++ console without breaking the input in one line at a time? If i use cin i can input one string each time plus i cannot edit the input (except if i edit the string but this wont help) Is there any way to input strings (with multiple lines) but not to break the string in one line at a time?

I am running ubuntu 12.04

解决方案

Who is writing? Is it you, or some program??

Your terminology is unusual: generally programmers take the point of view of the computer!

What you write by typing on your keyboard is an input to some program (which reads it).

If you want an editable input (to the program, so "written" or typed by the human user), consider using GNU readline (on Linux), or perhaps ncurses

If you want to format the program's output (which the user would read with his eyes), you'll generally need to code that formatting explicitly. Perhaps ANSI escape codes might be useful (but using them might make readline or ncurses unhappy).

See also this answer and the references I gave there.

这篇关于我如何在c + +控制台写文本,而不打破线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆