How to make colored output

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2006
Posts: 254
Reputation: jan1024188 is an unknown quantity at this point 
Solved Threads: 2
jan1024188's Avatar
jan1024188 jan1024188 is offline Offline
Posting Whiz in Training

How to make colored output

 
0
  #1
Dec 30th, 2006
ok here I want to know how to make colorated output in C and C++...

For example: I want to print this string "zelena". The color must be green. Now how to get green output using printf() in C and cout << "zelena";

Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: How to make colored output

 
0
  #2
Dec 30th, 2006
Simple, use the SetConsoleTextAttribute() method from the Windows API
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 254
Reputation: jan1024188 is an unknown quantity at this point 
Solved Threads: 2
jan1024188's Avatar
jan1024188 jan1024188 is offline Offline
Posting Whiz in Training

Re: How to make colored output

 
0
  #3
Dec 30th, 2006
Originally Posted by iamthwee View Post
Simple, use the SetConsoleTextAttribute() method from the Windows API
Yeah, but i want to get colored output using printf() function...

Also I`m still complete n00b..
Last edited by jan1024188; Dec 30th, 2006 at 6:44 am.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,273
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 378
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: How to make colored output

 
0
  #4
Dec 30th, 2006
You can still use it with printf.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Aug 2006
Posts: 254
Reputation: jan1024188 is an unknown quantity at this point 
Solved Threads: 2
jan1024188's Avatar
jan1024188 jan1024188 is offline Offline
Posting Whiz in Training

Re: How to make colored output

 
0
  #5
Dec 30th, 2006
Im realy confused now...could you write an example?
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 598
Reputation: SpS is on a distinguished road 
Solved Threads: 32
SpS's Avatar
SpS SpS is offline Offline
Posting Pro

Re: How to make colored output

 
0
  #6
Dec 30th, 2006
Originally Posted by jan1024188 View Post
Im realy confused now...could you write an example?
Search the snippets section. You'll find code for that.
Reply With Quote Quick reply to this message  
Join Date: Nov 2005
Posts: 251
Reputation: dwks has a spectacular aura about dwks has a spectacular aura about 
Solved Threads: 25
dwks's Avatar
dwks dwks is offline Offline
Posting Whiz in Training

Re: How to make colored output

 
0
  #7
Dec 30th, 2006
dwk

Seek and ye shall find.

"Only those who will risk going too far can possibly find out how far one can go."
-- TS Eliot.

"I have not failed. I've just found 10,000 ways that won't work."
-- Thomas Alva Edison

"The only real mistake is the one from which we learn nothing."
-- John Powell
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 45
Reputation: apurv is an unknown quantity at this point 
Solved Threads: 3
apurv apurv is offline Offline
Light Poster

Re: How to make colored output

 
0
  #8
Jan 6th, 2007
every chatacter occupies 2 Bytes in VDU memeory.
First is for its ascii value, while next for its color.
To change the color of the text, u need to change this Byte.
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 45
Reputation: apurv is an unknown quantity at this point 
Solved Threads: 3
apurv apurv is offline Offline
Light Poster

Re: How to make colored output

 
0
  #9
Jan 6th, 2007
Originally Posted by apurv View Post
every chatacter occupies 2 Bytes in VDU memeory.
First is for its ascii value, while next for its color.
To change the color of the text, u need to change this Byte.
U must be able to right the required code for this now.
and one more thing, forget 'printf'
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 3096 | Replies: 8
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC