0

How to add colour to text in c++?

#include <iostream> using namespace std; int main() { cout << "******* \n * \n * \n * \n * \n * \n******* \n\n"; cout << " * \n * \n * \n * \n * \n ****** \n\n"; cout << " * \n * * \n * * \n * * \n *\n\n"; cout << " * * \n * * \n * * * \n\n"; cout << " **** \n * \n **** \n * \n ****\n\n"; cout << " * * * * \n ** ** * * \n * * * * * \n * * * \n * * *"; return 0; }

1st Apr 2018, 11:59 AM
S K Sahil Mandal
S K Sahil Mandal - avatar
9 Réponses
+ 3
Gordie In Windows 10, ANSI escape sequences do, in fact, work (awesome, right?). I used them in my Python chat client.
1st Apr 2018, 2:35 PM
LunarCoffee
LunarCoffee - avatar
+ 3
Gordie Not only PS, but also the regular old command prompt. 😃 also i definitely didn't just brick my brand new oneplus 5t
1st Apr 2018, 2:43 PM
LunarCoffee
LunarCoffee - avatar
+ 2
A recent windows 10 update brought ANSI escape to 32 win console. I suppose it's part of their effort to emulate Linux on Windows.
1st Apr 2018, 3:20 PM
Daniel
Daniel - avatar
+ 1
There is no (standard) cross-platform way to do this. On windows, try using conio.h. It has the: textcolor(); // and textbackground(); functions. For example: textcolor(RED); cprintf("H"); textcolor(BLUE); cprintf("e"); // and so on.
1st Apr 2018, 12:09 PM
Baraa AB
Baraa AB - avatar
+ 1
wlcm 💙
1st Apr 2018, 12:14 PM
Baraa AB
Baraa AB - avatar
0
thanxxx
1st Apr 2018, 12:11 PM
S K Sahil Mandal
S K Sahil Mandal - avatar