Program to Calculate Length of a String (Using strlen in-built function)

Output:
Enter the string: Learn C Online
The length of the string is 14.

You may also like...

4 Responses

  1. Anonymous says:

    thanx

  2. Anonymous says:

    plz post for Without using strlen().

  3. Adeel Ehsan says:

    #include
    #include
    int string_ln(char*);
    int main()
    {
    char str[20];
    int l;
    printf(“Enter any string:n : “);
    gets(str);
    l=string_ln(str);
    printf(“The length of the given string %s is : %d”,str,l);
    getch();
    }
    int string_ln(char*p) /* p=&str[0] */
    {
    int count=0;
    while(*p!=’\0′)
    {
    count++;
    p++;
    }
    return count;
    }

  1. April 12, 2015

    […] Calculate Length of a String (Using strlen in-built function) […]

Leave a Reply

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