Sunday, March 15, 2015

How to run C graphics program in Dev-C++

There are two ways to run C graphics program in Dev-C++:

First Process:

1) Download (http://bloodshed-dev-c.en.softonic.com/) and install Dev-C++.

2) Download WinBGIm 6.0 Dev-C++ package from      

     (http://www.nextwap.net/file/sRPS3XPN/winbgim-60-1g17l.html)

3) To Install WinBGIm 6.0 Dev-C++ package, go to Tools->Package Manager

            
            

Then Click ->Install Package->Add WinBGIm 6.0 Dev-C++ Package->Open->Next->Finish


4) Go to File->New->Project->Select WinBGIm->Project Name(my_first_gproject)->Ok

           

5) Write the following code:

               #include<stdio.h>
      #include<conio.h>
      #include<graphics.h>
      int main()
      {
        int gDriver=DETECT, gMode, midx=0,midy=0;
        initgraph(&gDriver, &gMode, " ");

        midx=getmaxx()/2;

        midy=getmaxy()/2;

        line(0,midy,getmaxx(),midy);

        line(midx,0,midx,getmaxy());

        circle(midx, midy, 100);


        getch();

        closegraph();
        return 0;
     }


6) Compile and run the program.
         
   

Second Process:

1) Download (http://bloodshed-dev-c.en.softonic.com/) and install Dev-C++.

2) Download WinBGIm (http://winbgim.codecutter.org/)

3) Extract the zip file.(Contains graphics.h winbgim.h and libbgi.a)

4) Copy graphics.h and winbgim.h files in include folder(C:\Dev-Cpp\include\) of your compiler directory.

5) Copy libbgi.a to lib folder (C:\Dev-Cpp\lib\) of your compiler directory.

6) Now Open Dev-C++ and create a new project. (Go to File-> New-> Project-> Project Name(my_first_gproject)->Ok)


           

7) Go to Project Menu->Project Options->Parameters

8) Copy the following code in the Linker field and click ok.

         -lbgi
        -lgdi32
        -lcomdlg32
        -luuid
        -loleaut32
        -lole32


           

9) Add a new file(first.c) to the project

            

10) Write the following code on first.c file:


        #include<stdio.h>
      #include<conio.h>
      #include<graphics.h>

      int main()
      {
        int gDriver=DETECT, gMode, midx=0,midy=0;

        initgraph(&gDriver, &gMode, " ");

        midx=getmaxx()/2;

        midy=getmaxy()/2;

        line(0,midy,getmaxx(),midy);

        line(midx,0,midx,getmaxy());

        circle(midx, midy, 100);


        getch();

        closegraph();
        return 0;
     }
11) Compile and run the program.

           


>>To know more about C graphics program, you may visit the following links:


     !!!Happy Programming!!!

1 comment:

Anonymous said...

Thank you.