Text Colour in C and cprintf() function
We can change the color of text in C. To do this use :
textcolor() in-built function.
This function selects a new character color in new text mode.
Syntax :
textcolor(int color);
Parameter :
int color is the value of color that is passed as the parameter.
We had already studied about color in the previous topic.
As color can be used either by passing the name of the color(in capitals) or its corresponding
value.
Hence both of these statement are correct :
textcolor(BLUE);
textcolor(1);
cprintf()
This function sends formatted text to the text window on the screen.
If you want to change textcolor then you have to use cprintf() function along
with textcolor().
Example :
#include <stdio.h>
#include <conio.h>
void main()
{
clrscr();
textcolor(2);
cprintf("Welcome to c colors!");
getch();
}
Output :
Prev NEXT
1 comments:
good content
Post a Comment