moveref function in c graphics

moveref function of c graphics is used to move the text from current position to relevent location.

General syntax of moveref function is: 
                                                  moveref(int offset-x, int offset-y);

It will take two arguments , both are integer datatypes. In which first argument is offset of x cordinate and second argument is offset of y cordinate.

For example:
Current position is (100,200) after use of moveref(200,300), now current position of text is (300,500).

C graphics program to demonstrate the moveref function

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

main()
{
   int gd = DETECT, gm, x, y;
   char msg[100],msg1[100];

   initgraph(&gd, &gm, "C:\\TC\\BGI");
   moveto(100,100);
   x = getx();
   y = gety();

   sprintf(msg,"Current x position = %d and y position = %d before moveref",x,y);
   outtextxy(10,20,msg);
   moverel(100, 200);

   x = getx();
   y = gety();

   sprintf(msg1, "Current x position = %d and y position = %d after moveref", x, y);
   outtextxy(10, 50, msg1);


   getch();
   closegraph();
   return 0;
}


moveref function in c graphics


0 comments:

Post a Comment