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

One thought on “C++ Program to Find Length of String Without Using Library Function

  1. tushar

    hey, i get a error that “gets should have a prototype”.

    Reply

Leave a Reply

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