How to Change Color of Text in C++

This is the basic and simple code of C++ program to change the text color. With different color beginners can make their out of C++ program attractive and stylish.

Source Code   

#include "stdafx.h"
#include <iostream>

#include <windows.h> // WinApi header

using namespace std;
int main()
{
cout<<"\a\n\n\n"
<<"\t******************************************************"<<endl
<<"\t** **"<<endl
<<"\t** Welcome To **"<<endl
<<"\t** Console Text Color **"<<endl
<<"\t** Demo **"<<endl
<<"\t** **"<<endl
<<"\t******************************************************"<<endl<<endl<<endl;cout<<"";
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
for(int k = 1; k < 255; k++)
{
SetConsoleTextAttribute(hConsole, k);
cout << k << " Pro Programmer!" << endl;
}

system("pause");
return 0;
}

Output of the Program 


How to Change Color of Text in C++

Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment