Showing posts with label How to change colour of each line in console in Cplusplus. Show all posts
Showing posts with label How to change colour of each line in console in Cplusplus. Show all posts

Friday, 5 September 2014

Console Colour Changing in C++

Structure of the Problem Requirements 

In this problem we will learn about the colour changing in Console in C++ Program. For changing colour of text or background we include the windows.h class in C++ program. Windows library deal with such a events. In our program we make an instance of handle class and then use it to change the colour of the required lines. Here is the source code of this problem which help you in better understanding.

Source Code



#include<iostream>
#include<windows.h>
using namespace std;
int main ()
{
HANDLE h = GetStdHandle ( STD_OUTPUT_HANDLE );
SetConsoleTextAttribute(h,FOREGROUND_RED | FOREGROUND_INTENSITY);
cout<<"\t \t \t \t LEP \n \n \n ";
SetConsoleTextAttribute(h,FOREGROUND_GREEN | FOREGROUND_INTENSITY);
cout<<" CEO & Founders  :" <<" Asad Niazi & Naeem Sajid \n " <<endl;
SetConsoleTextAttribute(h,FOREGROUND_BLUE | FOREGROUND_INTENSITY);
cout<<"  Developers      :" <<" Niazi,Sajid,Anoshka Sharma,Rani,Zarlish,John Peter \n " <<endl;
SetConsoleTextAttribute(h,FOREGROUND_RED | FOREGROUND_INTENSITY);
cout<<"  Website         :" <<" WWW.ANCODINGPOINT.COM \n " <<endl;
SetConsoleTextAttribute(h,FOREGROUND_GREEN | FOREGROUND_INTENSITY);
cout<<"  Facebook Address:" <<" https://www.facebook.com/riphahiui \n " <<endl;
SetConsoleTextAttribute(h,FOREGROUND_BLUE | FOREGROUND_INTENSITY);
cout<<"  Twitter Address :" <<" https://twitter.com/LetsEnjoyProgra  \n " <<endl;
}

Output of the Program

Change Colour in Console
Change Colours in Console