使用C ++在Linux中的输出字符串覆盖终端上的最后一个字符串 [英] output string overwrite last string on terminal in Linux with c++

查看:47
本文介绍了使用C ++在Linux中的输出字符串覆盖终端上的最后一个字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一个命令行程序.有没有办法让我说

Say I have a command line program. Is there a way so that when I say

std::cout << stuff

如果我不执行 std :: cout<<'\ n'在另一个 std :: cout<<之间; ,,,,,,,的其他输出将覆盖同一行的最末尾的东西(清理行)?

if I don't do a std::cout << '\n' in between another std::cout << stuff, another output of stuff will overwrite the last stuff on the same line (cleaning the line) starting at the leftmost column?

我认为有能力这?如果可能的话,我可以说 std :: cout<<std :: overwrite<<东西

I think ncurses has the ability to do this? If possible, it would be great if I could say std::cout << std::overwrite << stuff

其中 std :: overwrite 是某种iomanip.

Where std::overwrite is some sort of iomanip.

推荐答案

您是否尝试过回车 \ r ?这应该做您想要的.

Have you tried carriage returns \r? This should do what you want.

这篇关于使用C ++在Linux中的输出字符串覆盖终端上的最后一个字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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