콘솔창은 형형색색으로 꾸며도 정말 촌스럽네요.
※소스 코드
#include <windows.h> #include <stdio.h> #define RED (FOREGROUND_RED | FOREGROUND_INTENSITY) #define BLUE (FOREGROUND_BLUE | FOREGROUND_INTENSITY) #define PINK (RED | BLUE) #define WHITE (RED | GREEN | BLUE) #define GREEN (FOREGROUND_GREEN | FOREGROUND_INTENSITY) #define YELLOW (RED | GREEN) #define SKYBLUE (GREEN | BLUE) #define RED_BG (BACKGROUND_RED | BACKGROUND_INTENSITY) #define BLUE_BG (BACKGROUND_BLUE | BACKGROUND_INTENSITY) #define PINK_BG (RED_BG | BLUE_BG) #define WHITE_BG (RED_BG | GREEN_BG | BLUE_BG) #define GREEN_BG (BACKGROUND_GREEN | BACKGROUND_INTENSITY) #define YELLOW_BG (RED_BG | GREEN_BG) #define SKYBLUE_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, BLUE, "파란색"); PrintString(hStdOut, PINK, "분홍색"); PrintString(hStdOut, WHITE, "하얀색"); PrintString(hStdOut, GREEN, "초록색"); PrintString(hStdOut, YELLOW, "노란색"); PrintString(hStdOut, SKYBLUE, "하늘색\n"); PrintString(hStdOut, RED_BG, "빨간배경"); PrintString(hStdOut, BLUE_BG, "파란배경"); PrintString(hStdOut, PINK_BG, "분홍배경"); PrintString(hStdOut, WHITE_BG, "하얀배경"); PrintString(hStdOut, GREEN_BG, "초록배경"); PrintString(hStdOut, YELLOW_BG, "노란배경"); PrintString(hStdOut, SKYBLUE_BG, "하늘배경\n"); PrintString(hStdOut, YELLOW_BG | PINK, "노란배경 빨간글씨"); PrintString(hStdOut, WHITE_BG | GREEN, "하얀배경 빨간글씨"); PrintString(hStdOut, GREEN_BG | WHITE, "초록배경 빨간글씨"); PrintString(hStdOut, BLUE_BG | RED, "파랑배경 빨간글씨"); CloseHandle(hStdOut); return 0; }
'C > 기타' 카테고리의 다른 글
[C언어] 플랫폼 독립적 COLORREF <-> RGB 서로 변환 (0) | 2014.03.12 |
---|