Is there a way to print colored output using iostream
and Xcode? I\'d like to be able to, for example, print Hello World!
with Hello
red,
Use {fmt} library, which is being slowly absorbed into C++ standard, starting with C++20 in header. Text colors and styles are not in the standard yet, AFAIK, but you can get them with the version on github, where you can find this example:
#include
int main() {
fmt::print(fg(fmt::color::crimson) | fmt::emphasis::bold,
"Hello, {}!\n", "world");
fmt::print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) |
fmt::emphasis::underline, "Hello, {}!\n", "мир");
fmt::print(fg(fmt::color::steel_blue) | fmt::emphasis::italic,
"Hello, {}!\n", "世界");
}