PROGRAMMING LANGUAGE/C++
출력할 때 글자색 바꾸기
JC0
2022. 1. 14. 20:34
#include <iostream>
#include <windows.h>
using namespace std;
void scolor(unsigned short text = 15, unsigned short back = 0)
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), text | (back << 4));
}
int main()
{
int a = 0;
for (int i = 0; i <= 15; i++)
{
scolor(0, a); printf("글자색값 : %02d - 배경색값 : %02d ", 0, a);
scolor(a, 0); printf("글자색값 : %02d - 배경색값 : %02d \n", a, 0);
a++;
}
return 0;
}