I want to change the color of the text in c++.
I am using Turbo c++ 4.5 and Windows XP.
I have used that textcolor(14) type code but it didn't work.
It says : Call to undefined function "textcolor" in function main
I have included header files iostream.h, conio.h, windows.h, dos.h.

Please suggest me the code which i can use to change the text color.

I want to change the color of the text in c++.
I am using Turbo c++ 4.5 and Windows XP.
I have used that textcolor(14) type code but it didn't work.
It says : Call to undefined function "textcolor" in function main
I have included header files iostream.h, conio.h, windows.h, dos.h.

Please suggest me the code which i can use to change the text color.

hei brother itz really easy All u have To do is type
#include<windows.h>
& after that type

SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 14);
change d final number
ex 12 = red ;
15=white
14=yellow
It is working on Visual C++ i hope it will aLSO work in turbo c++ also Wat is your country . Where r u from by the way tell me whether it is working or not....

Not working for me
Errors :
call to undefined function 'SetConsoleTextAttribute' in function main
call to undefined function 'GetStdHandle' in function main
undefined symbol 'STD_OUTPUT_HANDLE' in function main

#include <windows.h>
#include <iostream>
using namespace std;
 
int main()
{
   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), 5);
 
   cout << "I take back my first post and ask you to search DaniWeb first!" << endl;
 
   return 0;
}

You can change the value of 5 to anything that you like. I don't know the particular range. I'll leave that to you!

no that code is not working
the same error as i have mentioned in my first post.

no that code is not working
the same error as i have mentioned in my first post.

really? That last code works on my computer, if I remember it correctly, it turned the text into purple. I am guessing the problem is the compiler you are using. Try using Visual C++ Express Edition.

This article has been dead for over six months. Start a new discussion instead.