[C] 将系统设置成图形模式且清屏 →→→→→进入此内容的聊天室

来自 , 2019-06-05, 写在 C, 查看 115 次.
URL http://www.code666.cn/view/3de568f8
  1. #include <graphics.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <conio.h>
  5.  
  6. int main(void)
  7. {
  8.    /* request auto detection */
  9.    int gdriver = DETECT, gmode, errorcode;
  10.    int x, y;
  11.  
  12.    /* initialize graphics and local variables */
  13.    initgraph(&gdriver, &gmode, "");
  14.  
  15.    /* read result of initialization */
  16.    errorcode = graphresult();
  17.    if (errorcode != grOk)  /* an error occurred */
  18.    {
  19.       printf("Graphics error: %s\n", grapherrormsg(errorcode));
  20.       printf("Press any key to halt:");
  21.       getch();
  22.       exit(1); /* terminate with an error code */
  23.    }
  24.  
  25.    x = getmaxx() / 2;
  26.    y = getmaxy() / 2;
  27.  
  28.    /* output a message */
  29.    settextjustify(CENTER_TEXT, CENTER_TEXT);
  30.    outtextxy(x, y, "Press any key to exit graphics:");
  31.    getch();
  32.  
  33.    /* restore system to text mode */
  34.    restorecrtmode();
  35.    printf("We're now in text mode.\n");
  36.    printf("Press any key to return to graphics mode:");
  37.    getch();
  38.  
  39.    /* return to graphics mode */
  40.    setgraphmode(getgraphmode());
  41.  
  42.    /* output a message */
  43.    settextjustify(CENTER_TEXT, CENTER_TEXT);
  44.    outtextxy(x, y, "We're back in graphics mode.");
  45.    outtextxy(x, y+textheight("W"), "Press any key to halt:");
  46.  
  47.    /* clean up */
  48.    getch();
  49.    closegraph();
  50.    return 0;
  51. }
  52.  

回复 "将系统设置成图形模式且清屏"

这儿你可以回复上面这条便签

captcha