- 1
How can i output colored symbols in CPP?
Also in HTTP and Python.
2 Réponses
+ 3
Check out some libraries for C++
HTTP isn't a programming language
There is a module called Termcolor for Python
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.