C Program to Find Length of String

In this program, you'll learn to find length of a string.



Source Code
#include<stdio.h>

void main()
{
    char s[20];
    int i=0, len=0;

    printf("Enter the string\n");
    gets(s);

    while(s[i] != '\0')
    {
        len++;
        i++;
    }
    printf("Length of given string = %d", len);
    getch();
}
Output
Enter the string
Welcome to 'C'
Length of given string = 14





"Coding Hub - Learn to code" app now available on Google Play Store