I am writing a program in C. I want to change the text color and background color in the console. My sample program is -
#include
#include &
textcolor function is no longer supported in the latest compilers.
This the simplest way to change text color in Code Blocks.
You can use system function.
To change Text Color :
#include
#include //as system function is in the standard library
int main()
{
system("color 1"); //here 1 represents the text color
printf("This is dummy program for text color");
return 0;
}
If you want to change both the text color & console color you just need to add another color code in system function
To change Text Color & Console Color :
system("color 41"); //here 4 represents the console color and 1 represents the text color
N.B: Don't use spaces between color code like these
system("color 4 1");
Though if you do it Code Block will show all the color codes. You can use this tricks to know all supported color codes.