How do I color C++ text?

Does anyone know how to color C++ text?
Repl Link

This might help

1 Like

Yes! You can add color to c++ by using escape sequences.

For example -

#include <iostream>

int main()
    std::cout << "\033[1;31m"; // set color to bold red
    std::cout << "Hello, world!" << std::endl;
    std::cout << "\033[0m"; // reset color to default
    return 0;

It gives color red

Here ya go, most major colors and some font stuff:

Thanks! I’ve heard of esc codes but no sites (at least that I’ve seen so far) have given a very good explanation.

Thanks! I will be using this.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.