Hi,
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.
P.S.
I think spell check should recognize typical c++ expressions. etc. - like cout, endl.

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

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
{
private:
HANDLE hConsole;
public:
X()
{
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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.