📜  C语言中的closegraph()函数

📅  最后修改于: 2021-05-26 01:40:18             🧑  作者: Mango

头文件graphics.h包含closegraph()函数,该函数关闭图形模式,释放由图形系统分配的所有内存,并将屏幕恢复为调用initgraph之前的模式。

句法 :

void closegraph();

以下是C语言中closegraph()的实现。

// C Implementation for closegraph()
#include 
  
// driver code
int main()
{
    // gm is Graphics mode which is
    // a computer display mode that
    // generates image using pixels.
    // DETECT is a macro defined in
    // "graphics.h" header file
    int gd = DETECT, gm;
  
    // initgraph initializes the
    // graphics system by loading a
    // graphics driver from disk
    initgraph(&gd, &gm, "");
  
    // outtext function displays
    // text at current position.
    outtext("Press any key to close"
           " the graphics mode !!");
  
    getch();
  
    // closegraph function closes the
    // graphics mode and deallocates
    // all memory allocated by
    // graphics system .
    closegraph();
  
    return 0;
}

输出 :

注意:执行程序时,输出窗口如下所示。按下任意键时,closegraph()将关闭图形模式。

想要从精选的最佳视频中学习和练习问题,请查看《基础知识到高级C的C基础课程》。