Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8802069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:59:42+00:00 2026-06-14T00:59:42+00:00

I am running C in Code:Blocks IDE with the compiler GNU GCC . And

  • 0

I am running C in Code:Blocks IDE with the compiler GNU GCC. And I want to use colorful string output in my console application. The OS I am on is Windows

Previously, I used Borland C. So, using textcolor() textbackground() and cprintf() were fine. But these function does not seem to work on Code:Blocks IDE with GNU GCC Compiler wrapped with it.

What should I do to print colored texts now?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T00:59:43+00:00Added an answer on June 14, 2026 at 12:59 am

    Color in a terminal is built into standard Windows, and it’s pretty easy. You want the SetConsoleTextAttribute() function, here’s a very quick example:

    #include <stdio.h>
    #include <Windows.h>
    #include <string.h>
    
    void main()
    {
        printf("Hello\n");  // Print white text on black output
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_RED);
        printf("Hello Again!\n");  // Print Red text on black output
        getchar(); // Pause the program to admire the colors
    }
    

    For further highlighting you can also change the back ground, you can OR (|) together flags to get different colors and different back/fore grounds.

    So if you wanted to do red text on a green back ground (for some reason) you could do:

    FOREGROUND_RED | BACKGROUND_GREEN
    

    enter image description here

    You can also mix colors by OR’ing more than one foreground or background color for example:

    FOREGROUND_GREEN | FOREGROUND_BLUE
    

    Will give you a blue-green colored text.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I am running below code in Code::Blocks in Windows OS. I used to
I want to use shift-tab for auto completion and shifting code blocks visually. I
Hello I am using Code::Blocks in Windows XP. When I am running this program
I am running Code::Blocks 10.05 with the MingW compiler package on a Win7-32 box.
I am running a C program in Code :: Blocks in windows XP. I
I am running code to produce outputs where I want all the outputs to
I have a thread in my application that is running code that can potentially
I am currently running the latest version of Code-blocks in Ubuntu 11.04. I have
Im using Ubuntu 10.10, Code::Blocks with GCC 4.2. I have written a code like
While running following code, my program crashes unexpectedly! #include<stdio.h> #include<string.h> int main(){ char *str

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.