Displays a string of text in graphics mode at a specified location.Takes the string as well as the position of display from the user.
/******************************************************** * * Demonstrates text printing in graphics mode * * code.cheraus.com * ********************************************************/ #include<iostream.h> #include<conio.h> #include<graphics.h> int main() { int gd=DETECT; int gm; clrscr(); //clears the screen in TurboC(available in conio.h header file) int x1,y1; //variables to hold the co-ordinates char mes[50]; //variable to store the string from the user //taking the line inputs from user cout<<"Enter the string to be displayed: "; cin>>mes; //taking co-ordinates of the point where the string will be displayed cout<<"Enter the x co-ordinate of point: "; cin>>x1; cout<<"Enter the y co-ordinate of point: "; cin>>y1; /* initialization of graphics mode. The third argument takes the path of the graphics driver in your computer. If you have it in some other directory then specify the appropriate path;otherwise it may not work. */ initgraph(&gd,&gm,"C:\\turboc3\\bgi"); // clears the screen in graphics mode cleardevice(); //function to display the string in graphics mode.Takes the point co-ordiante as well as string as argument. outtextxy(x1,y1,mes); //gets a character from the user before exiting the program getch(); //closes the graphics mode closegraph(); //return from main function. Indicates successful run return 0; }