That will be enough to change the background color of the text.
How to use text color in dev c++. To set background colors you have to combine the foreground color code with the background color code using this equation. For exampleyou can write textcolorYELLOW. In C programming the background of the output screen is black and text color is in white color.
You will have to pass the name of the color or corresponding value which is shown in the table in the parameter of the function in which color you want to display the character on the screen or. It is used to set the color of the character in Text Mode. This function sets the attributes of characters written to the console screen buffer by the WriteFile or WriteConsole functions.
But if you want to change the text color without changing the background color you need to do a little bit more work. Where color is an integer variable. Use the textcolor function to define what color you want to use for text.
You could type 4 instead of RED but it is not as readable. To change text color to YELLOW. To use the textbackground function all you need to do is before printing any text call this function with a parameter defining the color in capital letters.
Include include main textcolorRED. Textcolor int color. Blue is 1 and white is 15.
Finalcolor 16backgroundcolor foregroundcolor if you want to set a text color that has a blue background and white text you simply look up the color code in the table. In this video I will show you how to print out unicode text using console applications on Windows in CCWe will use this function in our example. Use SetConsoleTextAttribute Method to Change Console Color in C SetConsoleTextAttribute is the Windows API method to set output text colors using different parameters.