Whenever we are asked to write a program to find length of string, we make use of inbuilt function- strlen (). Obviously, it is the easy method and we can use that. But sometimes, we are asked not to use the strlen (). This program helps to find length of strings without using strlen ().
#include <stdio.h>
#include<conio.h>
void main()
{
char str[20];
int i = 0;
printf(“\n Enter any string to find the length of it : “);
gets(str);
while (str[i] != ‘\0’)
i++;
printf(“\n Length of string entered is : %d”, i);
getch();
}
Latest posts by Mohit Arora (see all)
- MongoDB Operators Tutorial – What are Different Operators Available? - October 5, 2019
- MongoDB Projection Tutorial : Return Specific Fields From Query - March 9, 2019
- MongoDB Index Tutorial – Create Index & MongoDB Index Types - July 6, 2018