About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Tuesday, September 3, 2013

C Program to Find Length of String Using Library Function

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

printf("\nEnter the String : ");
gets(str);

len = strlen(str);

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

Explanation of Program :

We need to find the length of the string using library function provided by C Programming.
len = strlen(str);
strlen() function will evaluate the length of the string and return the string length (i.e integer value).
#include<string.h>
We need to include string.h header file in order to use string manipulation functions in c program.

No comments: