Ask coding questions

← Back to all posts
Colored Text in c++
SelenaYang1 (4)

How do you make colored text in c++?
is it possible?



Answered by DynamicSquid (3294) [earned 5 cycles]
View Answer
DynamicSquid (3294)

Since uses a Linux compiler, yes, it is possible:

for example, if you want black text: "\033[0;30mThis text will be black"

EpicGamer007 (420)

@DynamicSquid, It's to bad it does not work on windows :(

Coder100 (6992)

try replacing \033 to x1b @AbhayBhat

Coder100 (6992)

Hello. You can use ANSI escape codes (the escape code is \x1b):

cout << "\x1b[31mRed Text\x1b[0mNormal text";

View all of them here