Search code examples
c++linuxncursesiomanip

output string overwrite last string on terminal in Linux with c++


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

std::cout << stuff

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?

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

Where std::overwrite is some sort of iomanip.


Solution

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