[C / C ] Text color in Dev-C – How do change color of text in Dev C

To write text color in Dev-C you can simply use the command system(“color xy”);
Where x is the background color, y is the text color:
text color in dev-C++

But on the way back with an error if the entire set different color font color will be there, ie the colored letters that we finally put color. To fix it you have to learn and know the function (library use windows.h) on congdongcviet.com

void SetTeColor(WORD color)
{ 
	HANDLE hConsoleOutput;
	hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_SCREEN_BUFFER_INFO screen_buffer_info;
	GetConsoleScreenBufferInfo(hConsoleOutput, &screen_buffer_info);
	WORD wAttributes = screen_buffer_info.wAttributes;
	color &= 0x000f;
	wAttributes &= 0xfff0; wAttributes |= color;
	SetConsoleTextAttribute(hConsoleOutput, wAttributes);
}

After reading also do not understand what, but make it stable, Fixed color of the text as desired.