Textwidth() Function

textwidth() function returns the width of the specified string. textwidth() function gives the width of string which is based on the current setting of the settextstyle() function which is used to change font style family and direction of the text.

Declaration

int textwidth(char *string);
  • textwidth() function contains only one argument which represent the string whose width has to be calculated.
  • For better understanding go through the program:

Program

#include<stdio.h>

#include<conio.h>

#include<graphics.h>

void main()

{

int gd=DETECT, gm,w;

char arr[100];

initgraph(&gd,&gm," ");

w=textwidth("graphics programming");

sprintf(arr,"textwidth of given string=%d",w);

outtextxy(320,240,arr);

getch();

closegraph();

}

Above program gives the width of the string "graphics programming". textwidth() function is used to find out the width of the specified string.

Output

c graphics