GeekInterview.com
Series: Subject: Topic:
Question: 39 of 587

Print colors with printf

Is it possible to print colors with printf statements ?
Asked by: Interview Candidate | Asked on: Sep 27th, 2011
Showing Answers 1 - 4 of 4 Answers
brindha

Answered On : 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

  
Login to rate this answer.
kala725

Answered On : Dec 11th, 2011

View all answers by kala725

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.

Yes  1 User has rated as useful.
  
Login to rate this answer.
jbode

Answered On : Jun 3rd, 2012

View all answers by jbode

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.

  
Login to rate this answer.
Prashant Shetty

Answered On : 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

  
Login to rate this answer.

Give your answer:

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

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.