C++ 控制台代码输出控制
时间:2014-05-02 00:23:19
收藏:0
阅读:450
在C++控制台应用程序中可以控制控制台输出的字体颜色和 接受任意按键退出
#ifndef CONSOLE_UTILS_H
#define CONSOLE_UTILS_H
#include <windows.h>
#include <conio.h>
#include <iostream>
//default text colors can be found in wincon.h
inline void SetTextColor(WORD colors) {
HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute(hConsole, colors);
}
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
评论(0)