login about faq

Due to the large amount of spam accounts, we temporarily disabled new user sign ups. To override this, email newuser.lgqa@gmail.com and an admin will determine if you are permitted to join


I am using conio currently. (A newby) I know there are 16 colors, but no orange? Can I link another library for orange? Thanks!!

asked Nov 01 '12 at 19:31

Cory8u's gravatar image

Cory8u
361303544

what platform are you using, Windows? Linux? Mac?

(Nov 01 '12 at 21:00) trueb trueb's gravatar image

Try system("Color C"); it's the closest orange color in C++.

answered Nov 01 '12 at 19:51

Cameron's gravatar image

Cameron
1.8k104128136

Yellow... My pumpkin will look like a gourd.

(Nov 01 '12 at 20:05) Cory8u Cory8u's gravatar image

That's about the closest you're getting to orange. Sorry Bro

(Nov 01 '12 at 20:32) Cameron Cameron's gravatar image

using system commands should be avoided, it will work but not the best. It is important to start to practice good coding early on.

(Nov 01 '12 at 21:00) trueb trueb's gravatar image

For a windows system

First include windows.h with the other includes.

Next type this line of code:

HANDLE hCounsoleOut = GetStdHandle (STD_OUTPUT_HANDLE); //enable color change

next before you make a cout << "Hello World" command type the following

SetConsoleTextAttribute(hCounsoleOut, FOREGROUND_GREEN);

To explain a little what is going on, this function takes in a bitmap (not the image type but bits in a certain order.)

  • Without worrying about bits this is what you need to know: To change the text use FORGROUND_(some color here)

  • For the background you would type BACKGROUND_(some color here)

Now before you type in just any old color you need to know something, You can only type in Red Blue and Green. But you can type in more then one by doing the bit-wise operation OR (|) so here is an example:

SetConsoleTextAttribute(hCounsoleOut, FOREGROUND_GREEN | FOREGROUND_RED);

If you want to change the foreground and background both, no problems:

SetConsoleTextAttribute(hCounsoleOut, FOREGROUND_GREEN | BACKGROUND_RED);

There is one more thing to note, if you want to back the background or foreground brighter you can use INTENSITY here is an example:

SetConsoleTextAttribute(hCounsoleOut, FOREGROUND_RED | BACKGROUND_BLUE | FOREGROUND_INTENSITY);

answered Nov 01 '12 at 21:28

trueb's gravatar image

trueb
15.4k53104260

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported


Join Us in the Chat Room

Tags:

×69
×52
×12

Asked: Nov 01 '12 at 19:31

Seen: 378 times

Last updated: Nov 01 '12 at 21:28