You are here

textcolor in C

Function textcolor is used to change the color of drawing text in C programsTurbo C compiler only.

Declaration: void textcolor(int color);
where color is an integer variable. For example, 0 means BLACK color, 1 means BLUE, 2 means GREEN and soon. You can also use write appropriate color instead of integer. For example,you can write textcolor(YELLOW); to change text color to YELLOW. But use colors in capital letters only.

C programming code to change text color

  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4. main()
  5. {
  6.    textcolor(RED);
  7.    cprintf("C programming");
  8.  
  9.    getch();
  10.    return 0;
  11. }

C programming code for blinking text

  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4. main()
  5. {
  6.    textcolor(MAGENTA+BLINK);
  7.    cprintf("C programming");
  8.  
  9.    getch();
  10.    return 0;
  11. }

Note that we have used cprintf function instead of printf. This is because cprintf send formatted output to text window on screen and printf sends it to stdin.