any body can help me to change text colour? i am completly dizzy if you can help me!please reply the source code!i hope for it!
Here is a small c language program that will demonstrate how you can blink text in c language. you need to use a function textattr() which is present in IO library conio.h. The exact syntax of the function is void textattr(int newattr); This function enables you to set the color of the text as well as the color of the background of that text. So when you set the attribute of using textattr() function it will then format any output characters appearing on the screen after you call this funtion. Here is a table with all the values you can specify while calling textattr function. 7 6 5 4 3 2 1 0 B b b b F F F F F - these four bits define the text color. As you can have 16colors in turbo c. b - the combinations of these three bit sets the background color of the text. B - its the bit to blink the text. The text will blink if this bit is set to 1, otherwise the text will not blink. So assume that you want to blink the text in c language with black background and white text color. You will call textattr function as textattr(143); binary of 143 = 10001111 which turns the blink bit to 1, text color to white and background color to black. Or the most easy way is to use the color constants defined in conio.h. So the new syntax to blink the text in c programming language would be textattr(BLINK+BLACK+WHITE); There are some limitations on foreground and background colors, like you can not use white color as the background. Black, Blue, Green, Cyan, Red, Magenta, Brown, LightGray they all can be used both as text color and background colors. DarkGray, LightBlue, LightCyan, LightGreen, LightRed, LikeMagenta, Yellow, White can only be used as text colors. Code: #include <conio.h> #include <process.h></DIV> <DIV>void main(void) { int i;</DIV> <DIV> clrscr(); for (i=0; i<9; i++) { textattr(i + ((i+1) << 4)); cprintf("This is a test\r\n"); }</DIV> <DIV> getch(); } Try this!