How to change text color and console color in code::blocks?

后端 未结 8 1909
故里飘歌
故里飘歌 2020-12-08 17:29

I am writing a program in C. I want to change the text color and background color in the console. My sample program is -

#include 
#include &         


        
8条回答
  •  伪装坚强ぢ
    2020-12-08 18:21

    You can also use rlutil:

    • cross platform,
    • header only (rlutil.h),
    • works for C and C++,
    • implements setColor(), cls(), getch(), gotoxy(), etc.
    • License: WTFPL

    Your code would become something like this:

    #include 
    
    #include "rlutil.h"
    
    int main(int argc, char* argv[])
    {
        setColor(BLUE);
        printf("\n \n \t This is dummy program for text color ");
        getch();
    
        return 0;
    }
    

    Have a look at example.c and test.cpp for C and C++ examples.

提交回复
热议问题