C语言函数—gety

函数名

getx

功 能

返回当前图形位置的x坐标

用 法

int far getx(void);

程序例

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

int main(void) 
{ 
   /* request auto detection */ 
   int gdriver = DETECT, gmode, errorcode; 
   char msg[80]; 

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

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

   /* move to the screen center point */ 
   moveto(getmaxx() / 2, getmaxy() / 2); 

   /* create a message string */ 
   sprintf(msg, "<-(%d, %d) is the here.", getx(), gety()); 

   /* display the message */ 
   outtext(msg); 

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

如果引用本站的原创文章,请注明原文链接:,本站保留追究责任的权利!
评论已关闭。