发个带颜色的printf: enum zh color set COLOR BLACK =…

发个带颜色的printf:
enum zh_color_set {
COLOR_BLACK = 30,
COLOR_RED,
COLOR_GREEN,
COLOR_YELLOW,
COLOR_BLUE,
COLOR_MAGENTA,
COLOR_CYAN,
COLOR_WHITE
};
void zh_printf(int color, char *fmt, …)
{
va_list ap;
printf(“%c[1;%d;40m”, 0x1B, color);

va_start(ap, fmt);
vprintf(fmt, ap);
va_end(ap);

printf(“%c[0m”, 0x1B);
}

Leave a Reply

Your email address will not be published. Required fields are marked *