#define RED "\x1b[0;31m"
#define YELLOW "\x1b[0;33m"
#define RESET "\x1b[0m"
printf(RED"This text is red. \n"RESET); //This code works OK
The code below is what I want to do but it doesn't work. I want to change the text color based on the string variable color.
if (var > 5)
strcpy(color,RED);
else if (var > 3)
strcpy(color,YELLOW);
else
strcpy(color,RESET);
printf("%s My text to change color. \n",color); //the text color doesn't change
#define YELLOW "\x1b[0;33m"
#define RESET "\x1b[0m"
printf(RED"This text is red. \n"RESET); //This code works OK
The code below is what I want to do but it doesn't work. I want to change the text color based on the string variable color.
if (var > 5)
strcpy(color,RED);
else if (var > 3)
strcpy(color,YELLOW);
else
strcpy(color,RESET);
printf("%s My text to change color. \n",color); //the text color doesn't change