Captcha in C Language


Captcha in C Language (Turbo c )




If you have window xp then set this path "c:\\tc\\bgi".
For example  initgraph(&getdevice,&getmode,"c:\\tc\\bgi"); 
Write down  code for Captcha

#include<graphics.h>
#include<stdlib.h>

main()
{
   int i = 0, key, num, hx, getdevice = DETECT, getmode,color,maxx,maxy;
   char c[10];


   initgraph(&amp;getdevice,&amp;getmode,"c:\\turboc3\\bgi");


   setcolor(15);
   maxx=getmaxx();
   maxy=getmaxy();
   bar(0,0,maxx,maxy);
    hx = maxx/2;
    setcolor(0);
   settextstyle(1,0,1);
   outtextxy(hx,125,"");
   outtextxy(hx-50,180,"CAPTCHA");
   outtextxy(hx-100,150,"Press escape key to exit...");
   settextstyle(5,0,5);
   settextjustify(1,2);
   setviewport(100,200,600,400,1);
   setcolor(color);

   while(1)
   {
      while(i
&lt; 6)
    {
     num = random(3);

     if ( num == 0 )
        c[i] = 65 + random(26);     /* ASCII value of 65 to 90 is  A  to Z */
     else if ( num == 1)
        c[i] = 97 + random(26);     /* ASCII value of 97 to 122 is  a  to z */
     else
        c[i] = 48 + random(10);     /* ASCII value of 48 to 57 is 0 to 9 */
     i++;
      }
      c[i] = '\0';
      color=random(getmaxcolor());
      setcolor(color);
      outtextxy(210,100,c);

      key = getch();

      if( key == 27 )                     /* ASCII value of 27 is  escape key*/
     exit(0);
      clearviewport();
      i = 0;
   }
}

  
Save programm with '.c' extension.
for example captcha.c

ALT +  F9  through COMPILE program.


CTRL + F9   through RUN program.


Now see  Captacha in C language.
  
Thank you for read my post.

No comments: