How to setup graphics.h in Dev C++

 What is graphics.h file?

The graphic.h file is a header file that contains declarations of functions and variables for graphics programming in C or C++. It is part of the Borland Graphics Interface (BGI) library, which was originally developed for Turbo C and Turbo C++ compilers.

The graphics.h file provides access to simple graphics functions, such as drawing lines, circles, rectangles, polygons, and text on a graphical window. It also supports keyboard and mouse input, color manipulation, and loading and displaying images. To use the graphics.h file, you need to include it in your program with #include<graphics.h> and link the appropriate graphics driver and mode with the initgraph function.

What is initgraph function?

 The initgraph function is a graphics function in C or C++ that initializes the graphics system by loading a graphics driver and putting the system into graphics mode. It can be used to create graphical applications, such as drawing shapes, displaying images, and animating objects. The initgraph function has the following syntax:

The parameters of the initgraph function are :

Here are the steps for how to add graphics.h and libbgi.a file in Dev C++:


Step 1 :- Download the latest version of Dev C++ from here and install it on your computer.

follow the given step to add header file in your pc if you Stuck any where You can take help of video
Download the latest version of C++
Download the graphics header file
copy the file and paste in MinGW64(include) file location in Dev-Cpp
copy the file and paste in MinGW64(lib) file location in Dev-Cpp





Output of the given code
Output of above code

FAQs (Frequently Asked Questions) for Adding Graphics.h in Dev C++:

  1. What is graphics.h file in C or C++ programming?
  • The graphics.h file is a header file containing declarations of functions and variables for graphics programming, providing access to functions for drawing shapes, handling input, and manipulating colors.
  1. Which library is graphics.h part of, and for which compilers was it originally developed?
  • graphics.h is part of the Borland Graphics Interface (BGI) library, initially developed for Turbo C and Turbo C++ compilers.
  1. What functions does the graphics.h file offer for graphics programming?
  • It provides functions for drawing lines, circles, rectangles, polygons, text, as well as supporting keyboard and mouse input, color manipulation, and image loading and display.
  1. What is the purpose of the initgraph function in graphics programming?
  • The initgraph function initializes the graphics system by loading a graphics driver and putting the system into graphics mode, allowing for the creation of graphical applications.
  1. Can you explain the syntax of the initgraph function?
  • The syntax is void initgraph(int *graphdriver, int *graphmode, char *pathtodriver);. It takes parameters such as graphdriver (graphics driver), graphmode (initial graphics mode), and pathtodriver (directory path for graphics driver files).
  1. What are the parameters of the initgraph function and how are they used?
  • Parameters include Graphdriver (integer specifying the graphics driver), Graphmode (integer specifying the initial graphics mode), and Pathtodriver (string specifying the directory path for graphics driver files).
  1. How do you add graphics.h to Dev C++?
  • Download graphics.h, winbgim.h, and libbgi.a files, then copy graphics.h and winbgim.h to the Dev C++ include folder and libbgi.a to the lib folder. Adjust compiler options in Dev C++ and add required linker commands.
  1. What are the steps for adding graphics.h and libbgi.a in Dev C++?
  • The steps involve downloading Dev C++, graphics library files, copying files to Dev C++ folders, adjusting compiler options, and testing with a sample program.
  1. How do you check if graphics.h is working in Dev C++?
  • Write a simple program using graphics functions (e.g., drawing a circle), compile, and run. If the window displays the expected graphical output, graphics.h is working.
  1. Can I refer to a video for additional guidance on adding header files in Dev C++?
  • Yes, the article suggests referring to a video for more guidance if you encounter difficulties during the process of adding the header file.

Comments