Sunday, September 12, 2024

Printing Text in Graphics Using Outtextxy Function

#include<graphics.h>
#include<stdio.h>
int main(void)
{
   int gdriver = DETECT,gmode;
   int x=200, y=200;
   initgraph(&gdriver, &gmode, "c:\\tc\\bgi");
   outtextxy(x,y,"Hello World");
   closegraph();
}

Explanation :
outtextxy(x,y,"Hello World");
  • This Function is Similar to Printf Statement.
  • Printf Prints Text on Screen in "Text Mode" while outtextxy() function Prints Text onto Screen in "Graphics Mode".
  • This Function Accepts 3 Parameters.
Syntax :
outtextxy(X_Co-ordinate,Y_Co-ordinate,"Text");
ParameterExplanation
X_Co-ordinateSpecifies X Co-ordinate
Y_Co-ordinateSpecifies Y Co-ordinate
TextString/Text to be Printed On the Specified Co-ordinates

1 comments:

http://www.ps3.givafree.com/en/?refID=PS7254 said...

How do i print to a new line using this as "\n" isn't working

char *a;
a="Hello\nTest";
settextstyle(3,0,2);
outtextxy(100,20,a);

gives
Hello Test

Post a Comment

Your Feedback :This is Growing Site and Your Feedback is important for Us to improve the Site performance & Quality of Content.Feel Free to contact and Please Provide Name & Contact Email