- 1

How can i output colored symbols in CPP?

Also in HTTP and Python.

19th Apr 2017, 3:53 PM
CATrus 209
CATrus 209 - avatar
2 Respuestas
+ 3
Check out some libraries for C++ HTTP isn't a programming language There is a module called Termcolor for Python
1st May 2017, 2:58 PM
Ali Emir Kızıl
Ali Emir Kızıl - avatar
0
you can use simple_chalk instead of Termcolor for Python as for C++, you're going to need to use terminal color codes. For example: #include <iostream> #include <string> class Color { public: std::string red(std::string str) { str = "\033[31m" + str + "\033[0m"; return str; } } int main() { Color c; std::cout << c.red("my string") << std::endl; return 0; } This should output "my string" in red. \033[31m is the color code for red and \033[0m is to reset the colors (so they don't always show up as red). EDIT: Doesn't work in sololearn's c++ console. You're better off doing it in an IDE with an actual console.
10th Jul 2020, 12:57 AM
Parsec
Parsec - avatar