조회 수 29275 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
?

단축키

Prev이전 문서

Next다음 문서

+ - Up Down Comment Print
#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;
}

나눔글꼴 설치 안내


이 PC에는 나눔글꼴이 설치되어 있지 않습니다.

이 사이트를 나눔글꼴로 보기 위해서는
나눔글꼴을 설치해야 합니다.

설치 취소

Designed by sketchbooks.co.kr / sketchbook5 board skin

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5

Sketchbook5, 스케치북5