How to go up a line in Console Programs (C++)
animation, console-application, visual-c++
Solution
If your console supports VT100 escape sequences (most do), then you can use `ESC [ A`, like this:
cout << "\x1b[A";
to move the cursor up one line. Repeat as necessary.
Problem
In C++ I'm trying to go back up a line to add some characters. Here is my code so far: ``` cout << "\n\n\n\n\n\n\n\n\n\n\xc9\xbb\n\xc8\xbc"<<flush; Sleep(50); ``` As you can see, I have 10 newline characters. In my animation, a new block will be falling from the top of the screen. But I don't know how to go back up those lines to add the characters I need. I tried \r, but that dosen't do anything and \b dosen't go up the previous line either. Also, what exactly does flush do? I've only been programming in C++ for about 2 days so I'm a newb =P. Thanks so much!!! Christian