7 Replies - 24282 Views - Last Post: 26 August 2012 - 03:40 PM Rate Topic: -----

#1 chryne  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-October 09

font color in c++

Posted 05 October 2009 - 08:57 AM

how can i change my font color in c++? can you give me a sample code in changing font color
Is This A Good Question/Topic? 0
  • +

Replies To: font color in c++

#2 seeP+  Icon User is offline

  • D.I.C Addict

Reputation: 55
  • View blog
  • Posts: 601
  • Joined: 20-July 09

Re: font color in c++

Posted 05 October 2009 - 09:15 AM

For a windows machine you can use
system("COLOR 1e") this example will give you a blue background with light yellow text.
Was This Post Helpful? 0
  • +
  • -

#3 AGRAC393  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 3
  • View blog
  • Posts: 248
  • Joined: 13-May 09

Re: font color in c++

Posted 05 October 2009 - 09:24 AM

lmgtfy
Was This Post Helpful? 0
  • +
  • -

#4 seeP+  Icon User is offline

  • D.I.C Addict

Reputation: 55
  • View blog
  • Posts: 601
  • Joined: 20-July 09

Re: font color in c++

Posted 05 October 2009 - 09:28 AM

Here are the colors:
system("COLOR [background][text]");
O- black 9- light blue
1-blue a- light green
2-green b- light aqua
3-aqua c- light red
4-red d- light purple
5-purple e- light yellow
6-yellow f- bright white
7-white
8-gray
Was This Post Helpful? 0
  • +
  • -

#5 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: font color in c++

Posted 05 October 2009 - 11:15 AM

Why do people continue to use system to do these things?

Anyway, color in a C++ console application is pretty platform dependent. There are some cross platform libraries you can look into sucha as ncurses.

So, unless you look into one of those platform independent libraries, you will have to use the features of your target platform,

For example for windows you can see my Windows Console Output snippet which contains some basic functions for controlling the windows console.

There are also a number of other snippets for color in our snippets section.And those were just the ones that were easy to find!!!

(added to FAQ)

BTW: for any snippet developers out there... the Linux console colors is WAY under represented in our C/C++ snippets. I know we can get a few more out there... We have about a million windows ones and like what 1 Linux one? Where are the Linux programmer's at?
Was This Post Helpful? 2
  • +
  • -

#6 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5363
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: font color in c++

Posted 24 August 2012 - 07:04 AM

View PostNickDMax, on 05 October 2009 - 02:15 PM, said:

BTW: for any snippet developers out there... the Linux console colors is WAY under represented in our C/C++ snippets. I know we can get a few more out there... We have about a million windows ones and like what 1 Linux one? Where are the Linux programmer's at?

My Rock Paper & Scissors tutorial uses Linux console color changing text through a custom function & defines. Just adding this to your list (3 years later).
Was This Post Helpful? 0
  • +
  • -

#7 aresh  Icon User is offline

  • It's a 16-Bit World!
  • member icon

Reputation: 273
  • View blog
  • Posts: 4,176
  • Joined: 08-January 12

Re: font color in c++

Posted 25 August 2012 - 02:22 AM

I did not expect that you would necro a 3 year old topic....
Was This Post Helpful? 0
  • +
  • -

#8 no2pencil  Icon User is offline

  • Admiral Fancy Pants
  • member icon

Reputation: 5363
  • View blog
  • Posts: 27,325
  • Joined: 10-May 07

Re: font color in c++

Posted 26 August 2012 - 03:40 PM

It's listed under the C/C++ faq, feel free to post helpful comments.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1