Change the color of the text in c++ | SoloLearn: Learn to code for FREE!

+1

Change the color of the text in c++

I know i can change color but how i can change without change others?? Like this: hi(in red) hi(in blue)

c++

5/25/2020 5:20:50 PM

Lucas

8 Answers

New Answer

+1

Use graphics headerfile #include<graphics.h> And set graphics path And for text print Use outtextxy(pass two parameter nd seprate with comma, " text"); For color use Setcolor (color name );

+3

You really shouldn't give code for an outdated compiler as an answer.

+2

https://stackoverflow.com/questions/9965710/how-to-change-text-and-background-color

+2

Yes u can but not in sololearn compiler Try to use code blocks on pc Or cxxdroid apk And then use graphic lib like this

+2

Abhay the code doesnt works in windows

+2

Goodness me! Please don't use non standard headers from obsolete compilers such as Turbo C i.e. conio.h. There is no standard method for changing text colours in the standard output stream. As far as C/C++ is concerned the stdout stream is just that - a data stream. The standard does not mandate how that stream is implemented, it's capabilities, or it's dimensions.

+1

#include <conio.h> void main() { clrscr(); textcolor(RED); cprintf ("Welcome to Tutorial of Graphics in C/C++\n"); textcolor(LIGHTBLUE); cprintf("Hello\n"); getch(); }

+1

Abhay ok I am on it sololearn IDE is not as good as Codeblocks and the rest.