Mr. Hello_world
Mr. Hello_world

Reputation: 85

Change the color of the letter

How I can change the color of the letter in C++, I found that I could change the whole text color via

system("color 01")

but it changes all the text, how I can change the color of one letter/word?

Upvotes: 0

Views: 266

Answers (1)

Mr. Hello_world
Mr. Hello_world

Reputation: 85

Found it:

#include<windows.h>
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
    SetConsoleTextAttribute(h, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
    cout << "TIC TAC TOE GAME";
    SetConsoleTextAttribute(h, FOREGROUND_RED | FOREGROUND_INTENSITY);

Upvotes: 1

Related Questions