Skip to content

Instantly share code, notes, and snippets.

@keizerzilla
Last active September 3, 2018 11:17
Show Gist options
  • Save keizerzilla/0f8bd599887a373099195e68c56f9b85 to your computer and use it in GitHub Desktop.
Save keizerzilla/0f8bd599887a373099195e68c56f9b85 to your computer and use it in GitHub Desktop.
Formatting output with colors using printf() (C stdio.h). For more info: http://ascii-table.com/ansi-escape-sequences.php
#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