⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 colorconsole.cpp

📁 How to produce different colours on the DOS console using Windows function calls
💻 CPP
字号:
#
// color your text in Windows console mode
#
// colors are 0=black 1=blue 2=green and so on to 15=white
#
// colorattribute = foreground + background * 16
#
// to get red text on yellow use 4 + 14*16 = 228
#
// light red on yellow would be 12 + 14*16 = 236
#
// a Dev-C++ tested console application by vegaseat 07nov2004
#

#
#include <iostream>
#
#include <windows.h> // WinApi header
#

#
using namespace std; // std::cout, std::cin
#

#
int main()
#
{
#
HANDLE hConsole;
#
int k;
#

#
hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
#

#
// you can loop k higher to see more color choices
#
for(k = 1; k < 255; k++)
#
{
#
// pick the colorattribute k you want
#
SetConsoleTextAttribute(hConsole, k);
#
cout << k << " I want to be nice today!" << endl;
#
}
#

#
cin.get(); // wait
#
return 0;
#
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -