You are here

Textheight and textwidth functions in C

Declarations:

int textheight(char *string);
int textwidth(char *string);

Function textheight returns the height of a string in pixels and textwidth function returns the width of a string in pixels.

C program

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

int main()
{
  int gd = DETECT, gm, a, b;
  char arr[100];

  initgraph(&gd, &gm, "C:\\TC\\BGI");

  a = textheight("H");
  b = textwidth("H");

  sprintf(arr,"Textheight = %d, Textwidth = %d",a,b);
  outtext(arr);

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