I've been searching everywhere and can't believe how hard it is to find. I have the following code:
cout << "Hello";
cout << "Bye";
I want the first line to be green and the second line the be red. I managed to find:
system(" color 2");
However this makes all the text in the console green.
I only need it to work on Windows 7
Unfortunately. there's no native portable way to do this, as bash/linux will use ANSI escape codes (as did older DOS), but Windows XP or later will use the Console API (textcolor, etc) calls.
You might get a third party library that can provide a single API for both (ncurses/p-curses).
Have a look here