1#include <stdio.h>
2
3
4
5// [0;31m Red
6// [1;31m Bold Red
7// [0;32m Green
8// [1;32m Bold Green
9// [0;33m Yellow
10// [01;33m Bold Yellow
11// [0;34m Blue
12// [1;34m Bold Blue
13// [0;35m Magenta
14// [1;35m Bold Magenta
15// [0;36m Cyan
16// [1;36m Bold Cyan
17// [0m Reset
18
19
20
21
22int main () {
23 printf("\033[1;31m");
24 printf("Hello world\n");
25 printf("\033[0m;")
26 return 0;
27}
28
1//the following are UBUNTU/LINUX, and MacOS ONLY terminal color codes.
2#define RESET "\033[0m"
3#define BLACK "\033[30m" /* Black */
4#define RED "\033[31m" /* Red */
5#define GREEN "\033[32m" /* Green */
6#define YELLOW "\033[33m" /* Yellow */
7#define BLUE "\033[34m" /* Blue */
8#define MAGENTA "\033[35m" /* Magenta */
9#define CYAN "\033[36m" /* Cyan */
10#define WHITE "\033[37m" /* White */
11#define BOLDBLACK "\033[1m\033[30m" /* Bold Black */
12#define BOLDRED "\033[1m\033[31m" /* Bold Red */
13#define BOLDGREEN "\033[1m\033[32m" /* Bold Green */
14#define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */
15#define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */
16#define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */
17#define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */
18#define BOLDWHITE "\033[1m\033[37m" /* Bold White */
1#define RESET "\033[0m"
2#define BLACK "\033[30m" /* Black */
3#define RED "\033[31m" /* Red */
4#define GREEN "\033[32m" /* Green */
5#define YELLOW "\033[33m" /* Yellow */
6#define BLUE "\033[34m" /* Blue */
7#define MAGENTA "\033[35m" /* Magenta */
8#define CYAN "\033[36m" /* Cyan */
9#define WHITE "\033[37m" /* White */
10#define BOLDBLACK "\033[1m\033[30m" /* Bold Black */
1// For windows only
2#include <Windows.h>
3
4std::string textColor(int colorID = 1, std::string textToColor = "") {
5 SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colorID);
6 return textToColor;
7}
8
9// Usage: std::cout << textColor(1, "example");
10
11// Color ID's
12/*
131: Blue
142: Green
153: Cyan
164: Red
175: Purple
186: Dark Yellow
197: White
208: Grey
219: Bright blue
2210: Brigth green
2311: Bright cyan
2412: Bright red
2513: Pink
2614: Yellow
2715: Bright white
28*\
1 Black \033[0;30m
2
3 Red \033[0;31m
4
5 Green \033[0;32m
6
7 Yellow \033[0;33m
8
9 Blue \033[0;34m
10
11 Purple \033[0;35m
12
13 Cyan \033[0;36m
14
15 White \033[0;37m