简体   繁体   English

C ++-如何删除打印到控制台的换行符

[英]C++ - How to delete a newline that is printed to the console

As the title says, I am wondering how to delete a newline that is printed to the console, if it is possible. 如标题所示,我想知道如何删除可能打印到控制台的换行符。

I have seen the following: How to delete a newline using \\b 我已经看到以下内容: 如何使用\\ b删除换行符

Except that is about using \\b to delete a new line, and I would just like to know how to do it, using any possible method. 除了使用\\b删除新行外,我只想知道如何使用任何可能的方法来删除新行。

More specifically: If I have 更具体地说:如果我有

----
-  -
----

printed to the console, I would like to know how to delete the last two lines, to have just ---- . 打印到控制台,我想知道如何删除最后两行,只需要----

Thanks in advance! 提前致谢!

Note: I left out an OS to see if I can get an answer that would work on any OS. 注意:我省略了一个操作系统,以查看是否可以获得在任何操作系统上都可以使用的答案。

As I know, there is no portable way to work with not only current line of output, but with several lines on console. 据我所知,没有一种可移植的方式来处理当前的输出行以及控制台上的几行。

So you need some kind of wrapper around suitable functionality in each OS , the most portable library for this, as I know is: http://pdcurses.sourceforge.net/ 因此,您需要围绕每个OS合适功能的某种包装,为此,最方便的库是: http : //pdcurses.sourceforge.net/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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