Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Want to develop a CAPTCHA project on C language.
But i am getting an error: No such file or directory.
I am using GCC compiler.

Error Image: http://postimg.org/image/5ndmy0jk5/[^]

Objective-C
#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\\NULL");
 
   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);     /* 65 is the ASCII value of A */
         else if ( num == 1)
            a[i] = 97 + random(26);     /* 97 is the ASCII value of a */
         else
            a[i] = 48 + random(10);     /* 48 is the ASCII value of 0 */
         i++;
      }
      a[i] = '\0';
      outtextxy(210,100,a);
      key = getch();
 
      if( key == 27 )                     /* escape key*/
         exit(0);
      clearviewport();
      i = 0;
   }
}



Need urgent help...

Thanks....
Posted
Updated 30-Jul-13 10:53am
v2

1 solution

As you can see from your error message, the problem is not in your code, but in the setup of your compilation environment. Obviously the include file graphics.h cannot be found. So check the directory structure of your installation.
 
Share this answer
 
Comments
Atul Khanduri 30-Jul-13 17:18pm    
Actually sir i just switched from Turbo C to GCC compiler...
And i had developthat project using Turbo C...

So instead of initgraph(&gd,&gm,"C:\\TC\\BGI"); which is used in TurboC what code i have to write....
Is this Okey..??
initgraph(&gd,&gm,"NULL");
nv3 30-Jul-13 18:14pm    
I have no experience with Turbo C or its graphics library, but from what I see in the documentation the third parameter should be the path where your BGI files are. But this is not what is causing your compilation error. It is the #include in line 3 that is having trouble to find the graphics.h file. You have to set the C_INCLUDE_PATH environment variable so that your compiler finds your graphics.h file. This is the way to tell the compiler in which directory(ies) it should look to locate include files.
Atul Khanduri 31-Jul-13 2:05am    
I am not getting completely...
I am new in GCC....
Can you give me an example where this env. variable is located.... Means what to write in line3...!!!!
nv3 31-Jul-13 2:09am    
Take a look at the documentation of your compiler. There you will find information on how to install it correctly and where which directories should be placed.

This is not a problem in your program, but in how you have installed your compiler and libraries.
Atul Khanduri 31-Jul-13 2:32am    
My graphics.h is in "C:\MinGW\include" directory....

Now can you write line3...???

But graphics.h is in the same directory as dos.h and stdlib.h is located,,these are the two other header files used in my project....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900