Find length of string without using library function

Lets find length of string without using library functions.

Code 

#include<stdio.h>

int main() 
{
    char str[20];
    int length;

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

    length = 0;  

    while (str[length] != '\0')
            length++;

    printf("\nLength of the string = %d", length);
    return(0);
}

O/P













No comments:

Post a Comment