Answers for "set colors in printf"

1

printf output with color

#include <stdio.h>

#define KNRM  "x1B[0m"
#define KRED  "x1B[31m"
#define KGRN  "x1B[32m"
#define KYEL  "x1B[33m"
#define KBLU  "x1B[34m"
#define KMAG  "x1B[35m"
#define KCYN  "x1B[36m"
#define KWHT  "x1B[37m"

int main()
{
    printf("%sredn", KRED);
    printf("%sgreenn", KGRN);
    printf("%syellown", KYEL);
    printf("%sbluen", KBLU);
    printf("%smagentan", KMAG);
    printf("%scyann", KCYN);
    printf("%swhiten", KWHT);
    printf("%snormaln", KNRM);

    return 0;
}
Posted by: Guest on December-13-2020

Browse Popular Code Answers by Language