C++ Program to Find Length of String Without Using Library Function

Here you will get C++ program to find length of a string without using library function.

We iterate through the string until null character ‘\0’ is encountered and increase a counter variable for each iteration. Finally print the counter variable, it contains the length of string.

Output

Enter a string:hello hi

Length of the string ‘hello hi’ is 8

7 thoughts on “C++ Program to Find Length of String Without Using Library Function”

    1. I guess you did not read the title of the blog. It clearly says “Without using Library functions”. The function “strlen()” is library function.

Leave a Comment

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