Making Console output text colored in C++

Advertisements

  Top Tutorials     New Tutorials     Submit     Login     Register  

Tutorial Detail

Making Console output text colored in C++

Hello! I am going to show you, yes you, how to color your text in a console application using the WIN API.
http://www.radcpp.com/article.php?art_id=1170554318{76}
  • Total Hits: 11976

  • Average Rating :
    URL RatingURL RatingURL RatingURL RatingURL Rating

  •  

  • Total Votes: 139 votes

  • Category: C and C++/Game Programming

  • Submitted on: 2008-04-16 02:00:31

  • Submitted By: Shekhar

  • Set as Favorite

Description:

As you can now already see, it doesn't take much effort to make colored text.
The set_color function dose all of the magic. We start off by making a output handle. Then, we set
the console text using SetConsoleTextAttribute. Its first argument is what it should change. We use
the handle that we just made to tell it that we want to edit the color of the output text. The second argument
is the number of the color you want to change to. When you call the
set_color function, we put a number of the color we want to change
the text to. Try to figure out most of the colors on your own.
All I'm gonna say is if you give the function more then a one didget
number, the background color of the text will change, too.    More detail...

Rating Detail

 Stars  Percentage  Total Vote
 One star  Vote LeftVote MiddleVote Right 38.85%  54
 Two starsTwo star  Vote LeftVote MiddleVote Right 10.07%  14
 Three starsThree starsThree stars  Vote LeftVote MiddleVote Right 11.51%  16
 Four starsFour starsFour starsFour stars  Vote LeftVote MiddleVote Right 10.79%  15
 Five starsFive starsFive starsFive starsFive stars  Vote LeftVote MiddleVote Right 28.78%  40

Caste Your Vote

 Rating  Selection  Guidelines
 Poor:     Very disappointing, useless.
 Fair:     Below average, disappointing but not useless.
 Good:     About average in its class.
 Very Good:     Above average for its category.
 Excellent:     One of the best Tutorials in its category.





Advertisements
Advertisements