hi , i need to know how to change color of text . i tried but no goood . my actual program is too big so i will give small code by which u can tell me how can i change its color .
this is what i was trying , it is just an example . plz tell me whole procedure how to do it , by the way i am using turbo c++ 3.5 OR i have borland c++ 4.5
first dont use dos. secondly use iostream instead of iostream.h. thirdly use int main. fourthly http://www.cplusplus.com/articles/Eyhv0pDG/ however if your on a linux system i recommend ncurses. of couse since your on windows you can use windows.h
im pretty sure you have to make the .h file your self while i bet you just #included it, but whatever. try this:
using namespace std;
HANDLE hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
if (hStdout == INVALID_HANDLE_VALUE)
cout << "Error while getting input handle" << endl;
//sets the color to intense red on blue background
SetConsoleTextAttribute(hStdout, FOREGROUND_RED | BACKGROUND_BLUE | FOREGROUND_INTENSITY);
cout << "This is intense red text on blue background" << endl;
//reverting back to the normal color
SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
You are really being belligerent about the OP's platform. Go away.
The code you posted does not work when you compile and run it?
The issue might be that the Borland runtime is trying to access the video buffer directly. Read in the documentation to see how to turn that off. (I think there is a boolean variable you can toggle.) Otherwise you'll need to flag your program to run as a legacy application (from Explorer, right click and play with the stuff under the "Compatability" tab).