#include #include bool setConsoleFontSize(HANDLE console, COORD dwFontSize){ CONSOLE_FONT_INFOEX info{ sizeof(CONSOLE_FONT_INFOEX) }; if (!GetCurrentConsoleFontEx(console, false, &info)) return false; info.dwFontSize = dwFontSize; return SetCurrentConsoleFontEx(console, false, &info); } void getConsoleSize(HANDLE console, short & width, short & height){ CONSOLE_SCREEN_BUFFER_INFO bufferInfo; GetConsoleScreenBufferInfo(console, &bufferInfo); width = bufferInfo.srWindow.Right; height = bufferInfo.srWindow.Bottom; } void niceText(const char * text, unsigned short baseColor = 0x07, unsigned short specialColor = 0x07){ // ... HANDLE console = GetStdHandle(STD_OUTPUT_HANDLE); setConsoleFontSize(console, {12, 16}); short width, height; getConsoleSize(console, width, height); COORD centeredPosition = {width/2 - length/2, height/2}; COORD position = { centeredPosition.X, centeredPosition.Y }; unsigned long charactersWritten = 0; // ... } int main(int argc, char ** argv, char ** env){ niceText("I \03 C++", 0x07, 0x04); return 0; }