C program to find string length without using strlen()

C program to find string length

This program illustrate how to find string length without using strlen() . The program uses for loop to find length of string.

program

#include<stdio.h>
#include<conio.h>
void main()
{
char s[1000];
int z,i=0;
clrscr();
printf("Enter string: \n");
gets(s);
printf("Entered string is: %s ",s);
for(i=0;s[i]!='\0';++i)
{
z=i;
}
printf("\nLength of string is: %d",(z+1));
getch();
}

OUTPUT

find string length


Comment below if you are facing any problem and subscribe to our newsletter for more updates.


Also read

C program compare two strings using strcmp function
C program to check number of lowercase letters in a word
C program to check number of uppercase letter in a word
C program to copy string using Strcpy function


Summary
C program to find string length without using strlen()
Article Name
C program to find string length without using strlen()
Description
This program illustrate the concept to find string length without using strlen() finction.
Author
Publisher Name
Scanfcode
Publisher Logo

Leave a Reply

Your email address will not be published. Required fields are marked *