با سلام
این کار باعث میشه تمام خط ها به یه رنگ در بیاد اگر بخاهیم هر خط یک رنگ داشته باشه باید چیکار کرد؟
برای اینکه چند بار رنگ رو عوض کنید تو یه سایت دیدم این جوری نوشته بود:
#include <windows.h>
#include <iostream.h>

void main()
{
SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HA NDLE), 9); //replace the 0 with a number for the color you want
cout << "Your text here" << endl;

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HA NDLE), 5);
cout << "Your text here" << endl;
}
و برای ساده شدن استفاده یه تابع میشه تعریف کرد:

#include<windows.h>
#include<iostream.h>
enum Colors { blue=1, green, cyan, red, purple, yellow, grey, dgrey, hblue, hgreen, hred, hpurple, hyellow, hwhite };
void coutc(int color, char* output)
{
HANDLE handle= GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleTextAttribute( handle, color);
cout<< output<<flush;
}

void main()
{
coutc(red, "This is in red!");
coutc(purple, "This is purple!");
}