Computer Science Canada

changing text colours/background colours in console programs

Author:  jonos [ Thu Feb 12, 2004 10:03 pm ]
Post subject:  changing text colours/background colours in console programs

im trying to change the text colour in a console program and i think it's something like SetTextColor and SetBkColor or something but im not sure and i don't know what header to include. does anyone know how to do this?

Author:  Paul [ Thu Feb 12, 2004 11:22 pm ]
Post subject: 

there ain't many tutorials in the C/C++ section, maybe someone who knows this should make some tutorials, for everyone, if not only for Jonos' sake. On the basic stuff or something Laughing

Author:  Catalyst [ Thu Feb 12, 2004 11:58 pm ]
Post subject: 

i beleive that the borland compiler comes with a library and header that does thoes things

Author:  Dan [ Fri Feb 13, 2004 7:50 pm ]
Post subject: 

alougth it should be noted that it is unlike that it will work on all platforms....

the stantdered c or c++ complier/install dose not come with a graficks lib or comands like u whont. but there are any that can be dl online.

Author:  wtd [ Fri Feb 13, 2004 10:37 pm ]
Post subject: 

A curses interface may or may not get you what you need, but it can't hurt to look at the docs: http://www.cise.ufl.edu/~ppadala/ncdoc/html/ncintro/

Author:  octopi [ Sat Feb 14, 2004 12:25 am ]
Post subject: 

On windows, Nt strain. (maybe 9x)

code:
0 = Black       8 = Gray
1 = Blue        9 = Light Blue
2 = Green       A = Light Green
3 = Aqua        B = Light Aqua
4 = Red         C = Light Red
5 = Purple      D = Light Purple
6 = Yellow      E = Light Yellow
7 = White       F = Bright White


code:
color BF


Where F is the forground color, and B is the background color

code:
color e4

Will set the color to red, and the background to yellow



Use a system command to call this. Should work. (same as you would call cls, to clear screen)

Author:  jonos [ Sat Feb 14, 2004 11:44 pm ]
Post subject: 

isn't that for changing the screen colors in command prompt

edit:
i think i get it now, cause system("cls"); clears the screen, system does in the program what dos would do with that command?

Author:  jonos [ Sat Feb 14, 2004 11:51 pm ]
Post subject: 

okay, i just did that and it worked, so even though you don't need them to show my unending gratitude for your genius i will award thee with bits.

Author:  octopi [ Sun Feb 15, 2004 12:29 am ]
Post subject: 

Thanks for the bits....but I'm refunding them, because my bits automatically get reset to 1000, every so often... Cause I'm a mod.

Author:  jonos [ Sun Feb 15, 2004 9:17 am ]
Post subject: 

yeah, thats why i said you didn't really need them, but i couldn't really do anything else, so i gave you bits.

does the system("") function only work in windows or can it be used in linux just instead using system("linux command").

also, so does that mean i could do something like system("shutdown -s -c "hehe"")?

Author:  octopi [ Sun Feb 15, 2004 12:22 pm ]
Post subject: 

I think you mean single qoutes.

system("shutdown -s -c 'hehe'");


and I have no clue what the -s and -c options are for (my version of shutdown doesn't have either.)
You need to be root to shutdown the system....So yes, that command would work, it it was run as root.


: