在C++控制台应用程序中能够控制控制台输出的字体颜色和 接受任意按键退出ios
#ifndef CONSOLE_UTILS_Hwindows
#define CONSOLE_UTILS_H字体
#include <windows.h>it
#include <conio.h>io
#include <iostream>stream
//default text colors can be found in wincon.hnio
inline void SetTextColor(WORD colors) { 程序
HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE);di
SetConsoleTextAttribute(hConsole, colors);while
}
inline void PressAnyKeyToContinue() {
//change text color to white
SetTextColor(FOREGROUND_BLUE| FOREGROUND_RED | FOREGROUND_GREEN);
std::cout << "\n\nPress any key to continue" << std::endl;
while (!_kbhit()){}
return;
}
#endif