Check String Length in C++

Check String Length in C++

Check String Length in C++ :

This C++ Program is for the students of C/C++ they can use it in Data Structure subject to understand how different Text Processing Programs Check String Length in C++ or on other programming language using the same logic.

Here is the Line by Line explanation of given code

  1. Declare Header File
  2. Declare Header File
  3. Make a class with the name Temp
  4. Write Keyword “Public” to keep the function public under it.
  5. Write the name of the function Length which is taking value in Char a[].
  6. Into the function declare and integer len to store the length.
  7. Start a loop which will keep working till a[i] not equal to¬†‘\0’. This ‘\0’ represent ending value of string.
  8. in for loop body we are making increment of 1 in len integer.[From line 8 to 10]
  9. Printing out the length counted using loop.
  10. line 12 & 13 Closing function and Class respectively.
  11. Line 14-15 declare main function
  12. Declare an array with name b and size of 100.
  13. Line 17 making object of the class.
  14. Line 18-19 traditional C++ method to take input String to compute the length.
  15. Line 20 calling the length function using class object and passing the variable to the function in which we take input from user.

Here is the Code :

4 comments

  1. I do agree with all of the ideas you have offered on your post.
    They are very convincing and will certainly work. Nonetheless, the posts are very short for beginners.
    May just you please prolong them a little from next time?

    Thanks for the post.

Leave a Reply

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