DEV Community

Discussion on: Terminal colors in C/C++

Collapse
 
craqqed_ profile image
Gavin Hayes

is there any way to change the color of the output when using a variable? something like:
string word = "break";
cout << word << endl;
but with colors

Collapse
 
juanitotelo profile image
Juan David Martinez Mercado • Edited

maybe
cout << "\033[c1;c2" << word << "\033[0" << endl;
where c1 is the background color number and c2 is foreground color number.
:)