[英]Get rid of space when printing a new line using standard output in c++ and ncurses
Hello I'd like to know how to get rid of the space created when printing a new line in c++ using ncurses library. 您好,我想知道如何使用ncurses库在c ++中打印新行时摆脱创建的空间。
#include <iostream>
#include <ncurses.h>
using namespace std;
int main(){
initscr();
noecho();
cout << "Hello" << endl;
cout << "World" << endl;
endwin();
return 0;
}
I have this output 我有这个输出
Hello 你好
----World - - 世界
(The dashes are the space I mean) (破折号是我指的空格)
Offhand, I'd expect this output: 临时而言,我期望此输出:
Hello
World
since curses puts the screen into raw mode, suppressing the cooked-mode feature that converts output line-feeds into carriage-return/line-feed. 由于curses将屏幕置于原始模式,因此抑制了将输出换行转换为回车/换行的熟模式功能。 If you really want to print
如果您真的要打印
Hello
World
you should use curses calls (which also happen to work with curses output buffering ): 您应该使用curses调用(也可以在 curses输出缓冲中使用 ):
addstr("Hello\n");
addstr("World\n");
Besides the misformatted output, mixing cout
with curses can cause your output to be sent in a different order than the curses calls. 除了格式错误的输出外,将
cout
与curses混合使用可能会导致您的输出以不同于curses调用的顺序发送。 That's what I meant by buffering . 这就是缓冲的意思。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.