How to Change Text Color in CodeBlocks Console Window?

0
4510

In this tutorial, I will guide you through “How to Change Text Color in CodeBlocks Console Window”. The source code here is what you’re looking for if you want to change the text color in the console window of Code::Blocks without using graphics. You can simply copy the code, and compile it in Code::Blocks IDE. The source code is written in C language, and I have included comments in the code to help you understand it better.

The source code consists of two header files, windows.h and stdio.h which are the header file for windows and C standard library respectively. The function, void SetColor(int ForgC) takes integer values, and is responsible for the change in text color in console window.

Source Code:

Currently the text color displayed is Green color. You can change your desired text color by passing integer values (in the range of 0 to 256) in SetColor( ) function.

Here’s an output screen of what happened in the console window. As you can see, previously the text color was white, but after the function call, the text color changed to green.

How to Change Text Color in CodeBlocks Console Window
With this post, I hope you learnt how to change text color in CodeBlocks console window. You can also learn how to highlight or change text background color and how to change console window background color, all in Code::Blocks. If you have any queries, bring them up to me from the comments section.

LEAVE A REPLY

Please enter your comment!
Please enter your name here