C program to find the length of a string

C program to find the length of a string:
If you are using any software then below program will not give an error, but if you are using TURBO C then you have to make some changes like: void main() and some function like clrscr() or getch().

#include<stdio.h>
#include<string.h>
 main()
{
   char str[100];
   int len;

   printf("Enter the String : ");
   gets(str);

   len=strlen(str);

   printf("\nLength of Given String : %d",len);
}

OUTPUT:

Enter the String : BaronTuts

Length of Given String : 9

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.