closegraph
raw OCR
Shuts down the graphics system.
Defined in header <graphics.h>
Syntax
#include <graphics.h>
void far closegraph(void);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ |
Remarks
closegraph deallocates all memory allocated by the graphics system, then restores the screen to the mode it was in before you called inltgraph. (The graphics system deallocates memory, such as the drivers, fonts, and an internal buffer, through a call to _graphfreemem.)
Return value
None.
See also
initgraphsetgraph
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 (Sgdriver,-.&gmode, "");
/* read result of initialization */
errorcode = graphresult ();
if (errorcode != grOk) { /* an error occurred */
printfl"Graphics error: ls\n", grapherrormsg(errorcode)
printf ("Press any key to halt:");
getchO ;
exit(l); /* terminate with an error code */
}
X = getmaxx () / 2;
y = getmaxyO / 2;
/* output a message */
settextjustify (CENTER_TEXT, CENTER_TEXT);
outtextxy(x, y, "Press a key to close the graphics system:");
getchO; /* wait for a key */
/* closes down the graphics system */
closegraph {);
printf ("We're now back in text mode.\n");
printf ("Press any key to halt:");
getchO ;
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/graphics.h/closegraph/
· short form /3.1/closegraph/