Advertisement
metalx1000

Basic Text Colors in C

Feb 9th, 2015
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.12 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #define BLACK   "\x1b[30m"
  4. #define RED     "\x1b[31m"
  5. #define GREEN   "\x1b[32m"
  6. #define YELLOW  "\x1b[33m"
  7. #define BLUE    "\x1b[34m"
  8. #define MAGENTA "\x1b[35m"
  9. #define CYAN    "\x1b[36m"
  10. #define WHITE   "\x1b[37m"
  11. #define RESET   "\x1b[0m"
  12.  
  13. #define BOLD_ON    "\x1b[1m"
  14. #define INVERSE_ON "\x1b[7m"
  15. #define BOLD_OFF   "\x1b[22m"
  16.  
  17. #define BG_RED     "\x1b[41m"
  18. #define BG_GREEN   "\x1b[42m"
  19. #define BG_YELLOW  "\x1b[43m"
  20. #define BG_BLUE    "\x1b[44m"
  21. #define BG_MAGENTA "\x1b[45m"
  22. #define BG_CYAN    "\x1b[46m"
  23. #define BG_WHITE   "\x1b[47m"
  24.  
  25.  
  26.  
  27. int main () {
  28.  
  29.   printf(RED     "This text is RED!"     RESET "\n");
  30.   printf(GREEN   "This text is GREEN!"   RESET "\n");
  31.   printf(YELLOW  "This text is YELLOW!"  RESET "\n");
  32.   printf(BLUE    "This text is BLUE!"    RESET "\n");
  33.   printf(MAGENTA "This text is MAGENTA!" RESET "\n");
  34.   printf(CYAN    "This text is CYAN!"    RESET "\n");
  35.  
  36.   printf(CYAN BG_RED    "This text is CYAN!"    RESET "\n");
  37.   printf(RED BG_WHITE    "This text is RED!"     RESET "\n");
  38.   printf(BLUE BOLD_ON    "This text is BOLD!"     RESET "\n");
  39.  
  40.   return 0;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement