c++ color output code example
Example 1: c++ colored output
// For windows only
#include <Windows.h>
std::string textColor(int colorID = 1, std::string textToColor = "") {
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colorID);
return textToColor;
}
// Usage: std::cout << textColor(1, "example");
// Color ID's
/*
1: Blue
2: Green
3: Cyan
4: Red
5: Purple
6: Dark Yellow
7: White
8: Grey
9: Bright blue
10: Brigth green
11: Bright cyan
12: Bright red
13: Pink
14: Yellow
15: Bright white
*\
Example 2: c++ colored output
Black \033[0;30m
Red \033[0;31m
Green \033[0;32m
Yellow \033[0;33m
Blue \033[0;34m
Purple \033[0;35m
Cyan \033[0;36m
White \033[0;37m