This question has already been answered:

How to change the color of a single character in the console application. C language. Compiler - VS.

Reported as a duplicate by participants of BogolyubskiyAlexey , Yura Ivanov , Vladimir Martyanov , Kromster , Vitalii Obideiko 21 Sep '15 at 12:03 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

1 answer 1

  • For the console, call the SetConsoleTextAttribute function, passing the desired color of the character in the wAttributes argument.
  • For a window, call the SetTextColor function, also passing the desired text color to the argument.

After the character is displayed, return the previous color.

  • Can you give the working code? - doroga