Skip to content

Instantly share code, notes, and snippets.

@3dgoose
Created August 10, 2024 20:53
Show Gist options
  • Save 3dgoose/9e4da7cd4a0d00c0c1c03dad7836d20f to your computer and use it in GitHub Desktop.
Save 3dgoose/9e4da7cd4a0d00c0c1c03dad7836d20f to your computer and use it in GitHub Desktop.
Print with colors in a terminal, snippet in Airlib.
#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("%sred\n", KRED);
printf("%sgreen\n", KGRN);
printf("%syellow\n", KYEL);
printf("%sblue\n", KBLU);
printf("%smagenta\n", KMAG);
printf("%scyan\n", KCYN);
printf("%swhite\n", KWHT);
printf("%snormal\n", KNRM);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment