Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ colour text

//Read and Execute the code below to learn how to format system text in C++

#include <iostream> 
using namespace std;

int main(){
    cout<<"Printing most useful text format modes: ";
    
    cout<<"
1. x1b[1mBOLDx1b[0m";
    cout<<"
3. x1b[3mITALICx1b[0m";
    cout<<"
4. x1b[4mUNDERLINEx1b[0m";
    cout<<"
5. x1b[5mBLINKINGx1b[0m";
    cout<<"
7. x1b[7mHIGHLIGHTx1b[0m";
    cout<<"
8. x1b[8mPRINT NOTHINGx1b[0m";
    cout<<"
30. x1b[30mBLACKx1b[0m";
    cout<<"
31. x1b[31mREDx1b[0m";
    cout<<"
32. x1b[32mGREENx1b[0m";
    cout<<"
33. x1b[33mPURPLEx1b[0m";
    cout<<"
34. x1b[34mYELLOWx1b[0m";
    cout<<"
35. x1b[35mPINKx1b[0m";
    cout<<"
36. x1b[36mLIGHTBLUEx1b[0m";
    cout<<"
37. x1b[37mWHITEx1b[0m";
    cout<<"
40. x1b[40m Black Background      x1b[0m";
    cout<<"
41. x1b[41m Red Background        x1b[0m";
    cout<<"
42. x1b[42m Green Background      x1b[0m";
    cout<<"
43. x1b[43m Yellow Background     x1b[0m";
    cout<<"
44. x1b[44m Blue Background       x1b[0m";
    cout<<"
45. x1b[45m Pink Background       x1b[0m";
    cout<<"
46. x1b[46m Light Blue Background x1b[0m";
    cout<<"
-----------------------------------------------------";

    //Creating some string constants - shortcuts - combining text format modes
    const string RESET = "e[0m";   //Format Mode 0
    const string BOLD_HIGHLIGHT  = "e[1;7m";   //Format Modes 1 and 7
    const string COMPLEX_FORMAT_1 = "x1b[5;1;3;35;44m";  //Format Modes 5, 1, 2, 35 and 44
    const string COMPLEX_FORMAT_2 = "x1b[4;30;42m";      //Format Modes 4, 30 and 42
    const string COMPLEX_FORMAT_3 = "x1b[5;1m";      //Format Modes 5 and 1
    
    //Examples using shortcuts
    cout<<"

	** Program has been "<<BOLD_HIGHLIGHT<<"Terminated"<<RESET<<" **";
    cout<<"

	"<<COMPLEX_FORMAT_1<<"** Program has been Terminated **"<<RESET;
    cout<<"

	"<<COMPLEX_FORMAT_2<<"** Program has been Terminated"<<COMPLEX_FORMAT_3<<" **"<<RESET;
    
    cout<<endl;
    return 0;
}
Comment

how to add colored text in c++

#include <iostream>
#include <stdlib.h>

using namespace std;

int main()
{
    //Changing Font Colors of the System

    system("Color 7C");
    cout << "			 ****CEB Electricity Bill Calculator****			 " << endl;
    cout << "			  ***                MENU           ***			  " <<endl;

    return 0;

}
Comment

changue text color c++

// Change text color C++

// Colors http://es.tldp.org/COMO-INSFLUG/COMOs/Bash-Prompt-Como/Bash-Prompt-Como-5.html
#include <iostream>
using namespace std;


int main(){
  		string color = "33[31m RED";
        cout << "33[31m" <<"Text in Red"<<endl;
        return 0;
}
Comment

text color c++

#include <iostream>
#include <string>

int main(int argc, char ** argv){
    
    printf("
");
    printf("x1B[31mTexting33[0m		");
    printf("x1B[32mTexting33[0m		");
    printf("x1B[33mTexting33[0m		");
    printf("x1B[34mTexting33[0m		");
    printf("x1B[35mTexting33[0m
");
    
    printf("x1B[36mTexting33[0m		");
    printf("x1B[36mTexting33[0m		");
    printf("x1B[36mTexting33[0m		");
    printf("x1B[37mTexting33[0m		");
    printf("x1B[93mTexting33[0m
");
    
    printf("33[3;42;30mTexting33[0m		");
    printf("33[3;43;30mTexting33[0m		");
    printf("33[3;44;30mTexting33[0m		");
    printf("33[3;104;30mTexting33[0m		");
    printf("33[3;100;30mTexting33[0m
");

    printf("33[3;47;35mTexting33[0m		");
    printf("33[2;47;35mTexting33[0m		");
    printf("33[1;47;35mTexting33[0m		");
    printf("		");
    printf("
");

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: reference c++ 
Cpp :: Integer Moves codeforces solution 
Cpp :: c++ string_t to string 
Cpp :: c++ remove all elements equal to 
Cpp :: resharper fold statement 
Cpp :: how to check if vector is ordered c++ 
Cpp :: basic cpp 
Cpp :: if argv == string 
Cpp :: cmd color text c++ 
Cpp :: c++ check that const char* has suffix 
Cpp :: struct node 
Cpp :: stoi in c++ 
Cpp :: arduino falling edge 
Cpp :: flag of georgia 
Cpp :: c++ catch Unhandled exception 
Cpp :: len in cpp 
Cpp :: evennumbers 1 to 100 
Cpp :: c++ check if number is even or odd 
Cpp :: the difference between i++ and ++i 
Cpp :: C++ function inside main 
Cpp :: assign value to a pointer 
Cpp :: C++ switch..case Statement 
Cpp :: queue cpp 
Cpp :: cpprestsdk send file 
Cpp :: recuva recovery software for pc with crack 
Cpp :: the amount of input is unknown 
Cpp :: no of balanced substrings 
Cpp :: gdb get return value of function 
Cpp :: how to seek to the start of afile in c++ 
Cpp :: c++ dynamic array 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =