댓글 쓰기 권한이 없습니다. 로그인 하시겠습니까?
C
2005.08.05 15:02
콘솔 창에서 글자 색깔 바꾸기
조회 수 29275 댓글 0
#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; } Dreamy의 코드 스크랩내가 모으고 내가 보는
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Designed by sketchbooks.co.kr / sketchbook5 board skin
Sketchbook5, 스케치북5
Sketchbook5, 스케치북5
Sketchbook5, 스케치북5
Sketchbook5, 스케치북5