linux下使用printf打印输出不同颜色字体的方法

在linux用户层程序,串口打印输出不同颜色字体的方法:

s为要打印输出的字符串

#define PRINT_RED(s)    printf("\033[0;31m%s\033[0;39m",s);
#define PRINT_GREEN(s)    printf("\033[0;32m%s\033[0;39m",s);
#define PRINT_YELLOW(s)    printf("\033[0;33m%s\033[0;39m",s);
#define PRINT_BULE(s)    printf("\033[0;34m%s\033[0;39m",s);
#define PRINT_PURPLE(s)    printf("\033[0;35m%s\033[0;39m",s);/*紫色*/

在内核空间下,换printk()应该也是一样的效果,朋友们可以试一下,顺便把结果告诉我哈

猜你喜欢

转载自blog.csdn.net/qq_19004627/article/details/81705198