ANSI escape codes

closed account (42hU7k9E)
I need help with ANSI escape codes, i heard they are werry usefull, but i can't find nothing on google to learn about them. I am pretty new to programming so sorry if this is a stupid question.

So please if you have a good link to a tutorial or something, write it here.
closed account (42hU7k9E)
I have seen that, but how do i write it so that the computer will understand? :s
Example code to clear the screen:
char clearScreen[] = { 0x1b, '[', '2', 'J', 0 };
cout << clearScreen;

Will not work on a standard Windows Command window.
closed account (42hU7k9E)
It's true, it only outputs an arrow [ 2 j :) What should I do to make it work?
Google returns 76,600 results for "ansi escape codes"; you'll be alright. ;)
Kajec, Try reading the Wikipedia article!
You need to be running ANSI.SYS for those VT100 escape codes to work in a DOS console.

Presuming you are using Windows 2000 or later, somewhere in your console startup's autoexec.nt or config.nt file, you need to include the line


However, you are better off avoiding direct use of ANSI/VT100 control codes and programming the terminal properly. Google "msdn console functions" for stuff on Windows.

If you want to get really fancy, I recommend you check out the Curses library.

Win32, DOS, OS/2, Plan 9, etc.


Getting started with Curses

Remember that using the XSI standard Curses libraries means that it controls the console, so you shouldn't use the C and C++ standard console I/O streams concurrently. (You can use them elsewhere, of course, just don't mix them with console I/O.)

Hope this helps.
Last edited on
Topic archived. No new replies allowed.