當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


C語言 closegraph()用法及代碼示例


頭文件graphics.h包含closegraph()函數,該函數關閉圖形模式,釋放由圖形係統分配的所有內存,並將屏幕恢複為調用initgraph之前的模式。

用法:

void closegraph();

以下是closegraph()在C中的實現。


// C Implementation for closegraph() 
#include <graphics.h> 
  
// 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()將關閉圖形模式。



相關用法


注:本文由純淨天空篩選整理自Sahil_Bansall大神的英文原創作品 closegraph() function in C。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。