Which C++ function changes text or background color (MS Visual studio)? For example cout<<\"This text\"; how to make \"This text\" red color.
I believe that you are looking for the SetConsoleTextAttribute function. The first parameter, hConsoleOutput, would be the standard output handle obtained via GetStdHandle(STD_OUTPUT_HANDLE). The second parameter is a bitwise-OR (|) combination of the desired character attributes.
See also: KB319883 How to change foreground colors and background colors of text in a Console window by using Visual C#