Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Colour for beginners

Status
Not open for further replies.

functziah

Programmer
Jul 15, 2002
6
US
I am writing a relatively simple program in C (C++ not allowed) and need to emphasise on-screen text.

I would like to do this with colour but have no idea if this is even possible.

Functziah
 
if using unix try

man curses

it will show you all you need to know
 
Sorry no Unix. I compile in Visual or TC. (I'm just at the studying stage :)I)
 
Hmm, you should be able to use ansi-colors, ie. escape sequences to get colors.

I haven't tried this in win/dos for years, but in linux you can do this (it should work under win as well) :
printf("%c[34mBlue!!%c[37m\n", 27, 27);

(27 is the ASCII-code for <escape>)

This prints the text &quot;Blue!!&quot; with blue foreground.

The 37 resets the foreground to white afterwards since a change like this is done for ever, until one changes the color back. Try it out =)

Here is a link to a site where you can find out a lot of weird stuff one can do with escape sequences and a color of all color values (note that setting black fg on black bg is _not_ a lot of fun ;) )

Have fun!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top