C语言函数—movetext

函数名

moverel

功 能

将当前位置(CP)移动一相对距离

用 法

void far moverel(int dx, int dy);

程序例

#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 the C.P. to location (20, 30) */ 
   moveto(20, 30); 

   /* plot a pixel at the C.P. */ 
   putpixel(getx(), gety(), getmaxcolor()); 

   /* create and output a message at (20, 30) */ 
   sprintf(msg, " (%d, %d)", getx(), gety()); 
   outtextxy(20, 30, msg); 

   /* move to a point a relative distance */ 
   /* away from the current value of C.P. */ 
   moverel(100, 100); 

   /* plot a pixel at the C.P. */ 
   putpixel(getx(), gety(), getmaxcolor()); 

   /* create and output a message at C.P. */ 
   sprintf(msg, " (%d, %d)", getx(), gety()); 
   outtext(msg); 

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

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