You are here

Textheight and textwidth functions in c

Declarations :-

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

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

C programming code

  1. #include <graphics.h>
  2. #include <stdio.h>
  3. #include <conio.h>
  4.  
  5. main()
  6. {
  7.   int gd = DETECT, gm, a, b;
  8.   char arr[100];
  9.  
  10.   initgraph(&gd, &gm, "C:\\TC\\BGI");
  11.  
  12.   a = textheight("H");
  13.   b = textwidth("H");
  14.  
  15.   sprintf(arr,"Textheight = %d Textwidth = %d",a,b);
  16.   outtext(arr);
  17.  
  18.   getch();
  19.   closegraph();
  20.   return 0;
  21. }