#include <iostream> #include <Windows.h> using namespace std; enum Color { BLACK, BLUE, GREEN, CYAN, RED, MAGENTA, BROWN, LIGHTGRAY, DARKGRAY, LIGHTBLUE, LIGHTGREEN, LIGHTCYAN, LIGHTRED, LIGHTMAGENTA, YELLOW, WHITE }; void textcolor(int foreground, int background) { int color = foreground + background * 16; SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color); } int main() { textcolor(LIGHTBLUE, BLACK); cout << "Hello" << '\n'; return 0; }
textcolor 함수의 첫 번째 인자에는 글자 색, 두 번째 인자에는 글자의 배경색이 들어간다.
'C,C++' 카테고리의 다른 글
스마트 포인터(C++) (0) | 2019.04.19 |
---|---|
visual studio 2017 SFML 적용하기 (0) | 2019.01.15 |
fseek과 ftell로 파일의 크기 알아보기 (0) | 2018.12.26 |
C++ lower_bound, upper_bound (0) | 2018.12.26 |
콜라한캔 :: 16진수 문자열로 변환 (0) | 2018.12.23 |