0

I would like to know the generic way to do it. Therefore, imagine I print "hello world" and then I want to delete that line from the screen. How would you do it? Btw, is there a general way to do it? or there is a specific way depending on what you are trying to delete? Thanks in advance!

  • 1
    Does this answer your question? [How to remove last character put to std::cout?](https://stackoverflow.com/questions/3745861/how-to-remove-last-character-put-to-stdcout) – Daniel A. White Feb 08 '22 at 21:47
  • 2
    Print backspaces? Use a curses-like library? – Dave Newton Feb 08 '22 at 21:48
  • 1
    Imagine this: what if your terminal isn't a screen at all, but a teletype? As far as C++ knows, that may be the situation. – Fred Larson Feb 08 '22 at 21:54
  • IT depends on what device you outputted "Hello World" to. `C++` has no control over it. Different devices/terminal emulators have different control code sequences. Some more popular than others. – Galik Feb 08 '22 at 21:56
  • 1
    @FredLarson If you're sufficiently-aged to remember hammering out code on a [decwriter](https://en.wikipedia.org/wiki/DECwriter), as I am (started out on one first year in college), *respect*. – WhozCraig Feb 08 '22 at 22:00
  • @WhozCraig: Yep, been there, done that. – Fred Larson Feb 08 '22 at 22:02
  • 1
    There is no generic answer - the answer depends on which OS and which device (as mentioned by @Galik) you are using. Some devices are not capable of backspacing. Do you have a std::endl after the "Hello World"? – cup Feb 08 '22 at 22:17

0 Answers0