#include<graphics.h>
#include<conio.h>
#include<stdio.h>
#include<dos.h> // for delay() function
void main(void)
{
int driver=DETECT, mode;
int i; //for loop
initgraph(&driver, &mode, "c:\\TC\\bgi" );
textcolor(BLACK);
for(i=0;i<=400;i++)
{
clrscr();
setcolor(i/15); //set text/string color
outtextxy(20+i,150,"**C Language Codes**"); //see the description below
delay(30); //slow down the loop
}
getch();
closegraph();
}
What is outtextxy(); ?
It is a built-in function defined in the header file "graphics.h". This function used to display graphical string. The general syntax is as follows:
outtextxy(x-coordinate, y-coordinate, "String to display");
In the above program, outtextxy() function is put into for loop to make the text animated. As you can see that variable i is written with the x-coordinate whereas, the y-coordinate remains constant which means the text will move towards left to right on the screen.
If you still have any question, you can ask me freely...
0 comments:
Post a Comment