You are here

Textwidth function in c

Textwidth function returns the width of a string in pixels.

Declaration: int textwidth(char *string);

C programming source code for textwidth

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

int main()
{
   int gd = DETECT, gm, width;
   char array[100];

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

   width = textwidth("C programming");

   sprintf(array,"Textwidth = %d",width);
   outtext(array);

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

Share this