color text in C
Language: C
To color text in C, you can use escape sequences. Here's an example:
#include <stdio.h>
int main() {
printf("\033[0;31m"); // Set text color to red
printf("Hello, world!\n");
printf("\033[0m"); // Reset text color
return 0;
}
In this example, the escape sequence \033[0;31m
sets the text color to red, and \033[0m
resets the text color to the default. You can change the color by modifying the numbers in the escape sequence. For example, \033[0;32m
sets the text color to green.
Please note that the availability of text color may depend on the terminal or console you are using.