当前位置:早雪网网络学院编程文档C/C++ → C语言库函数(S类字母) - 1

C语言库函数(S类字母) - 1

减小字体 增大字体 作者:不详  来源:supcode.com收集整理  发布时间:2005-7-22 19:38:53
signed far setgraphbufsize(unsigned bufsize); 
程序例: 

#include <graphics.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <conio.h> 

#define BUFSIZE 1000 /* internal graphics buffer size */ 

int main(void) 

   /* request auto detection */ 
   int gdriver = DETECT, gmode, errorcode; 
   int x, y, oldsize; 
   char msg[80]; 

   /* set the size of the internal graphics buffer */ 
   /* before making a call to initgraph.           */ 
   oldsize = setgraphbufsize(BUFSIZE); 

   /* initialize graphics and local variables */ 
   initgraph(&gdriver, &gmode, ""); 

   /* read result of initialization */ 
   errorcode = graphresult(); 
   if (errorcode != grOk)  /* an error occurred */ 
   { 
      printf("Graphics error: %s\n", grapherrormsg(errorcode)); 
      printf("Press any key to halt:"); 
      getch(); 
      exit(1); /* terminate with an error code */ 
   } 

   x = getmaxx() / 2; 
   y = getmaxy() / 2; 

   /* output some messages */ 
   sprintf(msg, "Graphics buffer size: %d", BUFSIZE); 
   settextjustify(CENTER_TEXT, CENTER_TEXT); 
   outtextxy(x, y, msg); 
   sprintf(msg, "Old graphics buffer size: %d", oldsize); 
   outtextxy(x, y+textheight("W"), msg); 

   /* clean up */ 
   getch(); 
   closegraph(); 
   return 0; 

  
  
  

函数名: setgraphmode 
功  能: 将系统设置成图形模式且清屏 
用  法: void far setgraphmode(int mode); 
程序例: 

#include <graphics.h> 
#include <stdlib.h> 
#include <stdio.h> 
#include <conio.h> 

int main(void) 

   /* request auto detection */ 
   int gdriver = DETECT, gmode, errorcode; 
   int x, y; 

   /* initialize graphics and local variables */ 
   initgraph(&gdriver, &gmode, ""); 

   /* read result of initialization */ 
   errorcode = graphresult(); 
   if (errorcode != grOk)  /* an error occurred */ 
   { 
      printf("Graphics error: %s\n", grapherrormsg(errorcode)); 
      printf("Press any key to halt:"); 
      getch(); 
      exit(1); /* terminate with an error code */ 
   } 

   x = getmaxx() / 2; 
   y = getmaxy() / 2; 

   /* output a message */ 
   settextjustify(CENTER_TEXT, CENTER_TEXT); 
   outtextxy(x, y, "Press any key to exit graphics:"); 
   getch(); 

   /* restore system to text mode */ 
   restorecrtmode(); 
   printf("We're now in text mode.\n"); 
   printf("Press any key to return to graphics mode:"); 
   getch(); 

   /* return to graphics mode */ 
   setgraphmode(getgraphmode()); 

   /* output a message */ 
   settextjustify(CENTER_TEXT, CENTER_TEXT); 
   outtextxy(x, y, "We're back in graphics mode."); 
   outtextxy(x, y+textheight("W"), "Press any key to halt:"); 

   /* clean up */ 
   getch(); 
   closegraph(); 
   return 0; 

上一页  [1] [2] [3] [4] 

[数据载入中...] [返回上一页] [打 印]