Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save RigoLigoRLC/0960c9dab9e04c537664bf17907edace to your computer and use it in GitHub Desktop.
Save RigoLigoRLC/0960c9dab9e04c537664bf17907edace to your computer and use it in GitHub Desktop.
#include <windows.h>
#include <iostream>
int main()
{
CONSOLE_SCREEN_BUFFER_INFO info;
HANDLE hdl = GetStdHandle(STD_OUTPUT_HANDLE);
GetConsoleScreenBufferInfo(hdl, &info);
WORD wBackgroundColor = info.wAttributes & (BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE | BACKGROUND_INTENSITY );
SetConsoleTextAttribute(hdl, FOREGROUND_RED | FOREGROUND_INTENSITY | wBackgroundColor);
std::cout << "hello, world" << std::endl;
SetConsoleTextAttribute(hdl, info.wAttributes);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment