Hi I was just wondering how you change the text colour of only some of the text in a console when you are using cout to display your text.

I tried using

system("Color XY");

obviously where X and Y are hex numbers and X sets the background color and Y the foreground (or text) colour, but this isn't very useful since the whole screen just changes the the last set of colours in the code for that particular console display instead of just the selected text changing colour.

I wouldn't bother. Pointless in my opinion. It's rather hackish.

Can be done in much better way.

Hi I was just wondering how you change the text colour of only some of the text in a console when you are using cout to display your text.

it will all depend on the operating system. MS-Windows, use win32 api console functions. I don't know about *nix but probably use a curses library. You can download some free examples from here

Be a part of the DaniWeb community

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