Print colors with printf

Is it possible to print colors with printf statements ?

Showing Answers 1 - 12 of 12 Answers

brindha

  • Oct 9th, 2011
 

Printf is the statement only display what we are given inside the statement so if you are giving the colors in that statement it will display only the color name.

EX:

main()
{
printf("Red");
}

output:
Red

  Was this answer useful?  Yes

kala725

  • Dec 11th, 2011
 

There are already made functions in Header file Conio.h


textcolor(5) will change the color to the pink.similarly by changing the value we get different colors.

Not directly. The printf function simply sends formatted text to the output stream. However, with some terminals, you can send control codes as part of the formatted text, and these control codes can change the terminals display characteristics, including text color. For example, sending the sequence 33 to a terminal that understands ANSI escape sequences will clear the display. It depends on the terminal, though.

  Was this answer useful?  Yes

Prashant Shetty

  • Aug 17th, 2012
 

Include conio.h header file and textcolor(int value) function and dont forget to use cprintf statement :
ex:

Code
  1. textcolor(2);

  2. cprintf("hell world");

  3.  


now hello world will be displayed in yellow color

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions