0

Text color in C++

I'm curious about text color in C++. How can I create colored text in C++ programs ? How can print it on screen with cout instead of cprintf(). I'm using Code::Blocks 17.12

3rd Apr 2018, 6:14 AM
N1H4R
N1H4R - avatar
6 Respuestas
+ 2
For Windows just google “SetConsoleTextAttribute”. You’ll find the MSDN help and some good and easy examples.
3rd Apr 2018, 6:34 AM
Marius Heise
Marius Heise - avatar
+ 2
Standard C++ console output does not support colors. You have to use platform specific extensions to set the text color (foreground or background). Tell us what operating system you are developing under.
3rd Apr 2018, 6:18 AM
Marius Heise
Marius Heise - avatar
+ 2
For *nix you’ll have to use ANSI escape sequences.
3rd Apr 2018, 6:38 AM
Marius Heise
Marius Heise - avatar
+ 1
windows for now
3rd Apr 2018, 6:32 AM
N1H4R
N1H4R - avatar
+ 1
but what about linux. Because my primary OS is linux
3rd Apr 2018, 6:35 AM
N1H4R
N1H4R - avatar
0
@Marius Heise I'm using batch commands with system() to change text color but there is little problem. Can you help me ?
3rd Apr 2018, 5:33 PM
N1H4R
N1H4R - avatar