What does this code actually mean?

Jan 13, 2009 at 12:55am
Hello all, I am finally nearing the end of my first real program and I have this piece of code.

cout << "\x1b[2J\x1b[H" << flush;

I went searching the internet after reading the sticky about using system("cls") and being sucked into os dependent code. This code imo is possibly causeing the only bug in my software atm so im just curious to what it exactly does. I'm also using Code::Blocks if that matters.
Jan 13, 2009 at 1:36am
It looks like it is trying to send some ASCII escape character sequences. You could try looking up information on that and see what you come up with.
Jan 13, 2009 at 2:38am
I think I've seen that before. It's a really unreliable way to clear the screen in some system (I can't remember what right now). You'd do well to remove it without hesitation.
Jan 13, 2009 at 8:57am
closed account (z05DSL3A)
The code puts two ANSI/VT100 terminal control escape sequences into the output stream.

\x1b[2J is the code for clearing the screen and set cursor to home
\x1b[H is the code for returning the cursor to the home position.

It will only work on ANSI compliant terminals/consoles.

http://en.wikipedia.org/wiki/ANSI_escape_code
Topic archived. No new replies allowed.