codescracker


c

C Program to Find Length of String



« Previous Program Next Program »


Find Length of String in C

To find the length of the string in C programming, you have to ask to the user to enter the string and then find the length of that string using strlen() function of string.h library and display the length value of the string on the screen.

C Programming Code to Find Length of String

Following C program ask to the user to enter a string to find the length of that string using strlen() function, then display the result on the screen:

/* C Program - Find Length of String */
		
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
	clrscr();
	char str[20], len;
	printf("Enter a string : ");
	gets(str);
	len=strlen(str);
	printf("Length of the string is %d",len);
	getch();
}

When the above c program is compile and executed, it will produce the following result:

c program find length of string

Same Program in Other Programming Language

You may also like same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test