Adding color Text in C

In this article, we learn how to Display color font in the C programming language, without using getcolor() Function, Adding color Text in C like Opaque Text Color.

Text Color In C


// back ground colours
#define bgBlack “\e[40m”
#define bgRed “\e[41m”
#define bgGreen “\e[42m”
#define bgYellow “\e[43m”
#define bgBlue “\e[44m”
#define bgMagenta “\e[45m”
#define bgCyan “\e[46m”
#define bgWhite “\e[47m”

//bright background colours

#define bgbBlack “\e[40;1m”
#define bgbRed “\e[41;1m”
#define bgbGreen “\e[42;1m”
#define bgbYellow “\e[43;1m”
#define bgbBlue “\e[44;1m”
#define bgbMagenta “\e[45;1m”
#define bgbCyan “\e[46;1m”
#define bgbWhite “\e[47;1m”

// foreground light colours

#define fgBlack “\e[30m”
#define fgRed “\e[31m”
#define fgGreen “\e[32m”
#define fgYellow “\e[33m”
#define fgBlue “\e[34m”
#define fgMagenta “\e[35m”
#define fgCyan “\e[36m”
#define fgWhite “\e[37m”

//foreground bright colors

#define fgbBlack “\e[30;1m”
#define fgbRed “\e[31;1m”
#define fgbGreen “\e[32;1m”
#define fgbYellow “\e[33;1m”
#define fgbBlue “\e[34;1m”
#define fgbMagenta “\e[35;1m”
#define fgbCyan “\e[36;1m”
#define fgbWhite “\e[37;1m”

//reset foreground and background to normal colours

#define Reset “\e[0m”

void txtColor(char a[]);
void bgColor( char b[]);
int main()

printf(“\nThis is Blue Color “);

printf(” This is Green Color \n”);


printf(“This is Red Color text, Under White Color”);

return 0;

void txtColor(char a[]){

void bgColor(char b[]){


Get color in C program

Adding color Text in C
Adding color Text in C

Opaque Text Color In C



C program to draw a square using graphics (clickHere)

Color Font and Background in C

Note:- Maybe sometime above code doesn’t get user-friendly output, in codeblock ‘or’ any other EDITOR, All of C & C++ program tested in DOS compiler Turbo C.

Also Read

Types of functions in C    Read Here

I hope you will understand better if you study at M.U, in the exam of M.U you know how important this “Adding color Text in C

. So please don’t forget to give your valuable feedback. Go in the comment section and Give us some feedback about it. Adding color Text in C  or My website.

Our team check your every Comment per day Because your one feedback helps us in growing Thesmolt

I request you if you have any doubt or question regarding our site, then please don’t hesitate. We always waiting for your Suggestion.

Note:- If you want to Download This article’s in PDF form, then simply go (Top or Bottom of) Right corner and click on the PRINT icon, and it’s saved as a PDF of  Adding color Text in C

For further questions, you can contact us Via mail [email protected]  otherwise, Our Help Page and Contact us Page, which is included below. I hope I’ll able to say all the possible ways to reach us. Or Download My Android Application Below Download Button.

thesmolt App


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.