C Program to Find Length of a String Using strlen() Function


Aim :- Write a C Program to Find Length of a String Using strlen() Function.

C program to find string length using strlen function of "string.h" header file.
Function strlen is used to find length of a string.


C++ Program Code :


#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
      char str[6];
      int length;
      clrscr();
      printf("\nEnter the string : ");
      gets(str);
      length=strlen(str);
      printf("\nThe length of the string is %d",length);
      getch();
}


Output :

Post a Comment

0 Comments