Header file:
graphics.h
Synopsis:
int textheight(char *string);
Description:
textheight() returns the height of the given text in pixels.
textheight function in c graphics
#include <conio.h>
#include <graphics.h>
#include <string.h>
int main() {
/* request auto detction */
int gd = DETECT, gmode;
int err, ht, x, y;
char str[32];
/* initialize graphic driver and mode */
initgraph(&gd, &gmode, "C:/TURBOC3/BGI/");
err = graphresult();
/* error occurred */
if (err != grOk) {
printf("Error in graphics: %s\n",
grapherrormsg(err));
getch();
return 0;
}
x = y = 25;
strcpy(str, "Hello World!!");
/* outputs the given string at (x, y) */
outtextxy(x, y, str);
/* returns height of the given text in pixels */
ht = textheight(str);
/* outputs the given string at (x, y + ht) */
outtextxy(x, y + ht, str);
/* clean up */
getch();
closegraph();
return 0;
}
Output: (textheight built-in function in c graphics.h)
No comments:
Post a Comment