C output color font
To output colored text in C, you can use escape sequences. Here's an example of how you can achieve this:
#include <stdio.h>
int main() {
printf("\033[1;31mThis text will be displayed in red.\033[0m\n");
printf("\033[1;32mThis text will be displayed in green.\033[0m\n");
printf("\033[1;33mThis text will be displayed in yellow.\033[0m\n");
printf("\033[1;34mThis text will be displayed in blue.\033[0m\n");
printf("\033[1;35mThis text will be displayed in magenta.\033[0m\n");
printf("\033[1;36mThis text will be displayed in cyan.\033[0m\n");
printf("\033[1;37mThis text will be displayed in white.\033[0m\n");
return 0;
}
This code uses the escape sequence "\033[1;31m"
to set the text color to red, "\033[1;32m"
for green, "\033[1;33m"
for yellow, "\033[1;34m"
for blue, "\033[1;35m"
for magenta, "\033[1;36m"
for cyan, and "\033[1;37m"
for white. The escape sequence "\033[0m"
is used to reset the text color to the default.
When you run this code, the text within printf
statements will be displayed in the specified color.