In this program, we are going to share how to generate the Captcha using C programming language. If you are a beginner and want to start learning the C programming, then keep your close attention in this tutorial as I am going to share a C program to generate the Captcha.
Copy the below C program and execute it with the help of C compiler. At the end of this program, We have shared the output of this program.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | #include<stdlib.h> #include<dos.h> #include<graphics.h> main() { int i = 0, key, num, midx, gd = DETECT, gm; char a[10]; initgraph(&gd,&gm,"C:\\TC\\BGI"); midx = getmaxx()/2; settextstyle(SCRIPT_FONT,HORIZ_DIR,5); settextjustify(CENTER_TEXT,CENTER_TEXT); setcolor(GREEN); outtextxy(midx,20,"CAPTCHA"); settextstyle(SCRIPT_FONT,HORIZ_DIR,2); outtextxy(midx,125,"Press any key to change the generated random code \"captcha\""); outtextxy(midx,150,"Press escape key to exit..."); setcolor(WHITE); setviewport(100,200,600,400,1); setcolor(RED); randomize(); while(1) { while(i<6) { num = random(3); if ( num == 0 ) a[i] = 65 + random(26); else if ( num == 1) a[i] = 97 + random(26); else a[i] = 48 + random(10); i++; } a[i] = '\0'; outtextxy(210,100,a); key = getch(); if( key == 27 ) exit(0); clearviewport(); i = 0; } } |
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.
Article Tags: C program to generate captcha, c programs, c programs with output, c programs with solutions, Captcha Code In C, Captcha program in c, generate otp or captcha code in turbo c, how to code for CAPTCHA images in c, How to create CAPTCHAs using the C language, list of important c programs