[C] 清除图形屏幕 →→→→→进入此内容的聊天室

来自 , 2021-02-13, 写在 C, 查看 118 次.
URL http://www.code666.cn/view/3323fe11
  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 midx, midy;
  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.         midx = getmaxx() / 2;
  26.         midy = getmaxy() / 2;
  27.         setcolor ( getmaxcolor() );
  28.  
  29.         /* for centering screen messages */
  30.         settextjustify ( CENTER_TEXT, CENTER_TEXT );
  31.  
  32.         /* output a message to the screen */
  33.         outtextxy ( midx, midy, "press any key to clear the screen:" );
  34.  
  35.         /* wait for a key */
  36.         getch();
  37.  
  38.         /* clear the screen */
  39.         cleardevice();
  40.  
  41.         /* output another message */
  42.         outtextxy ( midx, midy, "press any key to quit:" );
  43.  
  44.         /* clean up */
  45.         getch();
  46.         closegraph();
  47.         return 0;
  48. }

回复 " 清除图形屏幕"

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

captcha