🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Changing text color in console applications with C++

Started by
0 comments, last by Yanroy 24 years, 7 months ago
Can anyone tell me how to change the text color in an MS-DOS type console window? I am running it under windows 98. I am using metrowerks codewarrior, which does not seem to like conio.h (causes a link error). At first I tried to use conio.h, but as I said just a second ago, it caused a link error. Then I tried to use the system() function to use the ANSI escape color codes from the MS-DOS prompt, only to find out that the Metrowerks Standard Library files have a system() function that doesn't do anything, and always returns 0! Please help!
--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

Advertisement
You can use

textcolor(x)

Where x is a number 0 - 15, and if you add 128 to x you can make it blink.

textcolor() is defined in the conio.h file, and you also have to make sure you use a writing function that supports the textcolor feature. cprintf() is one of them, which is basically the same thing as printf.

Working on: DoP

This topic is closed to new replies.

Advertisement