Software & Finance





Turbo C Graphics - Blink Characters and Words





Here is the graphics program that can display the word in different colors. It uses simple for loop and outtextxy along with setcolor commands.


Source Code


#include <dos.h>

#include <stdio.h>

#include <graphics.h>

#include <stdlib.h>

#include <conio.h>

 

void main()

{

      int grd, grm;

      int bgcolor, xmax, ymax,color,j;

      char buf[] = "http://www.softwareandfinance.com";

 

      detectgraph(&grd,&grm);

      initgraph(&grd, &grm, "");

 

      bgcolor = BLUE;

      setbkcolor(bgcolor);

 

      xmax = getmaxx();

      ymax = getmaxy();

 

      setcolor(WHITE);

      rectangle(0,0,xmax,ymax);

 

      settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);

      color = GREEN;

 

      for(j = 0; j <= 10; j++)

      {

            if( (j % 2) == 0)

            {

                  setcolor(color++);

                  outtextxy(20, 220, buf);

                  delay(1000);

                  if(color > WHITE)

                        color = GREEN;

            }

            else

            {

                  setcolor(bgcolor);

                  outtextxy(20, 220, buf);

                  delay(500);

            }

      }

      getch();

      closegraph();

}

 

Click here to download the source code along with exe file

Output


www.softwareandfinance.com will display in different colors.