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.

Recommended Answers

All 12 Replies

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....

hei ru online now

Hei it is workin guranteed i hav used it 4 several times . Check it

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

Use the textcolor function (it's not standard compliant) from conio.h library:

#include <conio.h>
int main()
{
textcolor(RED);
cputs("Red text in console!");
return 0;
}

http://www.ousob.com/ng/borcpp/ng6c57c.php

try using google next time!!

Error:call to undefined function 'textcolor' in function main

Post your code

i don't the code

#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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.