I know that this topic was discussed previously but those previous threads didn't answer to my question which is:
How to change color of this text:

cout << "Some text" << endl;

when I'm outside of main, i.e. in file with my class and in one of its fnc I have output like above and I would really, really change its colour.
Thank you.
I think spell check should recognize typical c++ expressions. etc. - like cout, endl.

9 Years
Discussion Span
Last Post by atch

Didn't see the other post about the system("color xx"), Removing the explanation as it was covered in the other thread.

Edited by grihalo: Didn't see other posts


Yeah, just use system("color 1F);
The 1F is just an example. they stand for the color's foreground and background. to view the different color choices go to command prompt and type color ?.


Yeah, just use system("color 1F);

I'm sorry guys but system(color xx); changes whole screen and I wanted to be able to change just particular output and after that output (with different colour) being made I wanted to output any other data in another coulour without changing colour of the first output.
Anyway I got this anyway after few mistakes.

class X
HANDLE hConsole;
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);

and after this construction I have an access to handle and I'm able to change colour properties (among others). In every tutorial I've read on the web the changing colour process was explained in main() and for someone inexperienced like me it's not obvious how would it work outside of main.
Thank you for all your answers.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.