撤消打印到命令行换行符(\\ n) [英] Undo a newline (\n) printed to command line
本文介绍了撤消打印到命令行换行符(\\ n)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
printf("Error %d\n", 1);
printf("\nStatus: %d%%", 50);
打印
Error 1
Status: 50%
在此成立,是没有任何机会,以插入错误2 \\ n
错误1 \\ n
之间 \\ n状态:50%
。据我所知, \\ r
和 \\ b
可用于更改打印文本的在同一个行(例如,如果有一个 \\ n
错误1
和状态之间: 50%
),但我可以在previous行更改文本?
In this set up, is there any chance to insert Error 2\n
between Error 1\n
and \nStatus: 50%
. I understand that \r
and \b
can be used to change printed text in the same line (e.g., if there is a single \n
between Error 1
and Status: 50%
), but can I change text in a previous line?
谢谢!
推荐答案
对不起,你不能。
但是,你可能会发出系统调用来清除整个屏幕,而不是像系统(清除)
(OS相关)。
But you may issue system calls to clear the whole screen instead, like system("clear")
(OS-dependent).
或者使用的ncurses
正如科斯在注释中。
Or use ncurses
just as Kos mentioned in the comment.
这篇关于撤消打印到命令行换行符(\\ n)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文