Featured Worklog

Price Search



PC Apex Sponsor


PC Apex Sponsors



PC Apex RSS Feeds

RSS Feed for PC Apex Reviews & ArticlesRSS Feed for PC Apex PC Modding WorklogsRSS Feed for the PC Apex Daily DisturbanceRSS Feed for the latest PC Apex Site NewsRSS Feed for PC Apex Affiliate and Web NewsRSS Feed for PC Apex Deals and Steals

Go Back   Apex Community Forums // Other Forums // Designers Corner // Coding / Scripting / Programming

Coding / Scripting / Programming Discussions on all manner of coding and scripting.

Reply
 
LinkBack Thread Tools Display Modes
Old 13-October-05, 03:56 PM   #1 (permalink)
Apex Master Tech
RAA_Kr1cH's Avatar
Default Changing text color in C++

This is way ahead of where my C++ 1 class is, but its been driving me nuts trying to figure out how to change colors in the dos box. What our teacher showed us was

system("color 3")

which depending on what number, or combination to 2 numbers changes the text and background colors. Unfortunately this changes the color of everything. What I want is a rediculously simple code that would allow me to change the text color of individual characters or lines of text. For example if I could do something like

cout << (RED) << "\nHello World!";

where it would change the color for just that particular line of code.

Thx
RAA_Kr1cH is offline     Reply With Quote
Sponsored Links
Old 13-October-05, 04:10 PM   #2 (permalink)
'Da Doctor of Funk
FunkyFresh's Avatar
Default

My first thought would be to use ANSI escape sequences:
http://www.evergreen.edu/biophysics/...m/ansi_esc.htm

So your code might look like:
cout << "\033[31;43mHello world\n"; // red on yellow
There are other ways too, using conio.h:
http://forums.dreamincode.net/index....0&#entry125754

EDIT: I seem to recall the "\033[" was the escape sequence on Unix; I think in DOS it's ASCII character 27.

Last edited by FunkyFresh; 13-October-05 at 04:24 PM.
FunkyFresh is offline     Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
SunBeam Chameleon Color Changing QUAD LED Laser Kit $2.99 coweater58 Deals and Steals 3 07-September-06 08:29 PM
Changing the color of a CCF Light Nexto Case Modding 11 31-March-05 05:48 PM
Icon text Background color Problem Fatsobob Windows OS Problems 17 01-February-05 08:31 PM
Changing the color of my keyboard. StatiK Painting 3 26-May-04 11:40 AM
Changing Drive color PowersurgeX Painting 3 05-February-03 04:57 PM


All times are GMT -5. The time now is 03:41 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC5
Copyright PCApex.com, GameApex.com, ForumApex.com 2001 - 2008
Advertisements

Page generated in 0.15525 seconds with 9 queries