To find out Length of a given string using C


Levels of difficulty: / perform operation:

C program to find out the length of a given string without using the library function strlen().

C Program

#include <stdio.h>
#include <conio.h>
void main()
{
	char str[50];
	int len;
	clrscr();
	printf("\nENTER A STRING: ");
	gets(str);
	for(len=0;str[len]!=NULL;len++);
	printf("\nTHE LENGTH OF THE STRING IS %d",len);
	getch();
}


Output