Find the string length in programming C and C++

Bismillahir Rahmanir Rahim
 Hi, friends.What's up? Now I'm showing you how can you find the string length.It's a simple program. To solve this problem we have to write

#include <string.h>
Otherwise the compiler show you error.
Solution: In C program :-

#include <stdio.h>
#include <string.h>
 
void main()
{
   char a[30];
   int length;
 
   printf("Enter a string to calculate it's length:\n");
   gets(a);
   /*http://iubatians.blogspot.com*/
   length = strlen(a);
   printf("Length of your entering string's = %d\n",length);
}
Solution:In C++ program:-

#include <iostream.h>
#include <string.h> 
void main()
{
   char a[30];
   int length;
 
   cout<<"Enter a string to calculate it's length:"<<endl;
   cin.getline(a,30);
   /* http://iubatians.blogspot.com */
   length = strlen(a);
   cout<<"Length of your entering string's=\t"<<length;
}
If you face any problem you can comment below or in facebook
Thank you for visiting my site.

Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →