在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