I decided to make this blog as I always need to find how to print coloured text, so this is my solution to it
# C++
# Code
#define ANSI_BEGIN "\x1B["
namespace AnsiColour {
const char *red = ANSI_BEGIN "31m";
const char *green = ANSI_BEGIN "32m";
const char *yellow = ANSI_BEGIN "33m";
const char *blue = ANSI_BEGIN "34m";
const char *magenta = ANSI_BEGIN "35m";
const char *cyan = ANSI_BEGIN "36m";
const char *white = ANSI_BEGIN "37m";
} // namespace AnsiColour
namespace AnsiEffect {
const char *bold = ANSI_BEGIN "1m";
const char *reset = ANSI_BEGIN "0m";
const char *underline = ANSI_BEGIN "4m";
} // namespace AnsiEffect
# Example usage
std::cout << AnsiColour::blue << AnsiEffect::bold
<< "Hello world" << AnsiEffect::reset << '\n';
# Code
#define ANSI_BEGIN "\x1B["
const char *CLR_RED = ANSI_BEGIN "31m";
const char *CLR_GREEN = ANSI_BEGIN "32m";
const char *CLR_YELLOW = ANSI_BEGIN "33m";
const char *CLR_BLUE = ANSI_BEGIN "34m";
const char *CLR_MAGENTA = ANSI_BEGIN "35m";
const char *CLR_CYAN = ANSI_BEGIN "36m";
const char *CLR_WHITE = ANSI_BEGIN "37m";
const char *EFF_BOLD = ANSI_BEGIN "1m";
const char *EFF_RESET = ANSI_BEGIN "0m";
const char *EFF_UNDERLINE = ANSI_BEGIN "4m";
# Example usage
printf("%s%sHello world%s\n", CLR_BLUE, EFF_BOLD, EFF_RESET);