How can I output text in different colors in a console program?
Each location in the console screen buffer has text attributes as well as a character associated with it, and the Win32 console functions can affect these in two ways. SetConsoleTextAttribute() affects subsequent characters written to the buffer, while FillConsoleOutputAttribute() directly changes the attributes of an existing block of text.