User Tools

Site Tools


Programming Reference/Librarys

Question & Answer

Q&A is closed

to support this page (eg 0,42 € or so) Thanks.


Syntax of closegraph

#include <graphics.h>
void closegraph(int wid=ALL_WINDOWS);

Description of closegraph

closegraph deallocates all memory allocated by the graphics system, then
restores the screen to the mode it was in before you called initgraph.
(The graphics system deallocates memory, such as the drivers, fonts, and
an internal buffer, through a call to _graphfreemem.)

Example of closegraph

/* closegraph example */
#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>
int main(void)
   /* request autodetection */
   int gdriver = DETECT, gmode, errorcode, x, y;
   /* initialize graphics mode */
   initgraph(&gdriver, &gmode, "");
   /* read result of initialization */
   errorcode = graphresult();
   if (errorcode != grOk) {   /* an error occurred */
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
exit(1);   /* terminate with an error code */
   x = getmaxx() / 2;
   y = getmaxy() / 2;
   /* output a message */
   settextjustify(CENTER_TEXT, CENTER_TEXT);
   outtextxy(x, y, "Press a key to close the graphics system:");
   getch();   /* wait for a key */
   /* closes down the graphics system */
   printf("We're now back in text mode.\n");
   printf("Press any key to halt:");
   return 0;

See also

output of closegraph example

  no output of example at the moment
  do not hesitate and add it...  
c/graphics.h/closegraph.txt · Last modified: 2015/05/06 23:06 (external edit)