#include <windows.h>
#include <cstdio>
#define RED (FOREGROUND_RED | FOREGROUND_INTENSITY)
#define GREEN (FOREGROUND_GREEN | FOREGROUND_INTENSITY)
#define BLUE (FOREGROUND_BLUE | FOREGROUND_INTENSITY)
#define YELLOW (RED | GREEN)
#define PINK (RED | BLUE)
#define SKYBLUE (GREEN | BLUE)
#define WHITE (RED | GREEN | BLUE)
#define RED_BG (BACKGROUND_RED | BACKGROUND_INTENSITY)
#define GREEN_BG (BACKGROUND_GREEN | BACKGROUND_INTENSITY)
#define BLUE_BG (BACKGROUND_BLUE | BACKGROUND_INTENSITY)
#define YELLOW_BG (RED_BG | GREEN_BG)
#define PINK_BG (RED_BG | BLUE_BG)
#define SKYBLUE_BG (GREEN_BG | BLUE_BG)
#define WHITE_BG (RED_BG | GREEN_BG | BLUE_BG)
void PrintString(HANDLE hStdOut, WORD Attribute, LPCSTR str) {
SetConsoleTextAttribute(hStdOut, Attribute);
puts(str);
}
int main() {
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);
PrintString(hStdOut, RED, "빨간색");
PrintString(hStdOut, GREEN, "초록색");
PrintString(hStdOut, BLUE, "파란색");
PrintString(hStdOut, YELLOW, "노란색");
PrintString(hStdOut, PINK, "분홍색");
PrintString(hStdOut, SKYBLUE, "하늘색");
PrintString(hStdOut, WHITE, "흰색");
PrintString(hStdOut, RED_BG, "빨간배경");
PrintString(hStdOut, GREEN_BG, "초록배경");
PrintString(hStdOut, BLUE_BG, "파란배경");
PrintString(hStdOut, YELLOW_BG, "노란배경");
PrintString(hStdOut, PINK_BG, "분홍배경");
PrintString(hStdOut, SKYBLUE_BG, "하늘배경");
PrintString(hStdOut, WHITE_BG, "흰배경");
PrintString(hStdOut, RED | YELLOW_BG, "노란배경의 빨간글씨");
// ...
CloseHandle(hStdOut);
return 0;
}