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 7443931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:24:36+00:00 2026-05-29T11:24:36+00:00

I know textcolor(); is for C++ and i’ve seen methods for unix… but is

  • 0

I know “textcolor();” is for C++ and i’ve seen methods for unix…
but is there way for windows also?

#include <stdio.h>
int main()
{
    printf("\ntest - C programming text color!");
    printf("\n--------------------------------");
    printf("\n\n\t\t-BREAK-\n\n");
    textcolor(15);
    printf("WHITE\n");
    textcolor(0);
    printf("BLACK\n");
    textcolor(4);
    printf("RED\n");
    textcolor(1);
    printf("BLUE\n");
    textcolor(2);
    printf("GREEN\n");
    textcolor(5);
    printf("MAGENTA\n");
    textcolor(14);
    printf("YELLOW\n");
    textcolor(3);
    printf("CYAN\n");
    textcolor(7);
    printf("LIGHT GRAY\n");
}

I can’t find any anything on the net…
let’s hope the good people from stack overflow can help 😀

C please, not C++

  • 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-05-29T11:24:37+00:00Added an answer on May 29, 2026 at 11:24 am

    Since you want a C and Windows specific solution, I’d recommend using the SetConsoleTextAttribute() function in the Win32 API. You’ll need to grab a handle to the console, and then pass it with the appropriate attributes.

    As a simple example:

    /* Change console text color, then restore it back to normal. */
    #include <stdio.h>
    #include <windows.h>
    
    int main() {
        HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
        CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
        WORD saved_attributes;
    
        /* Save current attributes */
        GetConsoleScreenBufferInfo(hConsole, &consoleInfo);
        saved_attributes = consoleInfo.wAttributes;
    
        SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE);
        printf("This is some nice COLORFUL text, isn't it?");
    
        /* Restore original attributes */
        SetConsoleTextAttribute(hConsole, saved_attributes);
        printf("Back to normal");
    
        return 0;
    }
    

    For more info on the available attributes, look here.

    Hope this helps! 🙂

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

Sidebar

Related Questions

I know there's a way to change the background color of a table, but
I know there's similar questions to this, but the approved answers don't seem to
I would like to know if there is a way where I can write
Know this might be rather basic, but I been trying to figure out how
I know that it's a subject that can raise a lot of debate, but
I know this is fairly subjective, but I'm diving into testing and learning about
I know this question has kind-a started religious wars in past and there might
I know this is largely an opinion, but I'm interested if you have one
I know how to set shadowColor on other view, but on ActionBarSherlock's title, shadow
Is there an easy way to grab a attribute value from an xml item

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.