The graphics.h file is used in C language to get basic graphics working in C.
Position Tracking
The positioning is done from the top left corner as shown in the image below,

Including graphics library
#include<stdio.h>#include<graphics.h>void main(){} |
Loading The Graphics Driver
#include<stdio.h>#include<conio.h>#include<graphics.h>void main(){int gdriver=DETECT,gmode;initgraph(&gdriver,&gmode," ");} |
References Of Common Functions
Cleardevice()
Clears screen
gotoxy()
Moves the cursor to a specific location on screen
putpixel()
Puts a small pixel(a very small dot) at the location mentioned in the function.
outtextxy()
Prints a text on the screen.
rectangle()
Draws a rectangle, given its starting and ending diagonal co-ordinates.
circle()
Draws a circle, given the coordinates of centre and the radius.
line()
Draws a line, given the starting and ending co-ordinates of the line.
moveto()
Moves the cursor, from one place to the position mentioned in the function.
lineto()
Draws a line from the current position to the co-ordinates specified.
ellipse()
Draws the ellipse using the specified angles and coordinates.
drawpoly()
Draws a polygon.
settextstyle()
Sets the font style. The available fonts are,
You may also change the size. The size is from 1 to 10.
setfillstyle()
Sets a style to fill up a shape. Styles available are SOLID_FILL, LINE_FILL, HATCH_FILL, SLASH_FILL etc.
setcolor()
Sets the color
floodfill()
Fills up the selected area with color.
itoa()
Converts from integer to alphabet.
delay()
Causes a delay in the execution of the program. The delay is given in miliseconds.
closegraph()
To close the graphics library.
Clears screen
gotoxy()
Moves the cursor to a specific location on screen
putpixel()
Puts a small pixel(a very small dot) at the location mentioned in the function.
outtextxy()
Prints a text on the screen.
rectangle()
Draws a rectangle, given its starting and ending diagonal co-ordinates.
circle()
Draws a circle, given the coordinates of centre and the radius.
line()
Draws a line, given the starting and ending co-ordinates of the line.
moveto()
Moves the cursor, from one place to the position mentioned in the function.
lineto()
Draws a line from the current position to the co-ordinates specified.
ellipse()
Draws the ellipse using the specified angles and coordinates.
drawpoly()
Draws a polygon.
settextstyle()
Sets the font style. The available fonts are,
- TRIPLEX_FONT
- SMALL_FONT
- SANS_SERIE_FONT
- GOTHIC_FONT
You may change the direction of the text to be displayed horizontally or vertically using HORIZ_DIR or VERT_DIR respectively.
You may also change the size. The size is from 1 to 10.
setfillstyle()
Sets a style to fill up a shape. Styles available are SOLID_FILL, LINE_FILL, HATCH_FILL, SLASH_FILL etc.
setcolor()
Sets the color
floodfill()
Fills up the selected area with color.
itoa()
Converts from integer to alphabet.
delay()
Causes a delay in the execution of the program. The delay is given in miliseconds.
closegraph()
To close the graphics library.

{ 10 comments... read them below or add one }
Farahad brother your efforts are admirable, i found this tutorial very helpful.
Thanks.
@Bilal: Brother thankyou very much. That means alot for me. I have collected this site data from various sources.
i want to create a table for making a sudoku game.
how should i start??
@Prateek:
Try making boxes by rectangle() function, then display the text by outtextxy() function.
sweet and simple!!
simple and to the point
delay() is in the dos.h header file i guess!!
sir how can i create trigonometric curves using c????
plz help me....!!!!
Which trigonometric function? All of them?
really helpful thank you sir
Post a Comment
Please Comment Back If The Code Has Helped.