Program to find the length of string in c language.

#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
 char str[20];
 int i,l;
 l=0;
 clrscr();
 printf("enter a string=");
 gets(str);
 for(i=0; str[i]!='\0'; i++)
 { 
  l=l+1;
 }
 printf("the length of string is =%d",l);
 getch();
}

■》 Output->

enter a string=ved varshney

the length of string is =12

Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.