Created
February 9, 2019 09:03
-
-
Save msetzu/22a2717498e98834c35e235b7398edc3 to your computer and use it in GitHub Desktop.
Colored printf in C
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
/* Colori definiti secondo lo standard ANSI/C */ | |
#define ANSI_COLOR_RED "\x1b[31m" | |
#define ANSI_COLOR_GREEN "\x1b[32m" | |
#define ANSI_COLOR_YELLOW "\x1b[33m" | |
#define ANSI_COLOR_BLUE "\x1b[34m" | |
#define ANSI_COLOR_MAGENTA "\x1b[35m" | |
#define ANSI_COLOR_CYAN "\x1b[36m" | |
#define ANSI_COLOR_RESET "\x1b[0m" | |
int main() { | |
printf(ANSI_COLOR_RED "Stringa rossa..\n"); | |
printf("Stringa ancora rossa.." ANSI_COLOR_RESET "\n"); | |
printf("Colore di default!\n\n"); | |
printf(ANSI_COLOR_RED "Stringa rossa.." ANSI_COLOR_RESET "Poi di default..." ANSI_COLOR_BLUE "Poi blu.\n" ANSI_COLOR_RESET); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment