Question: Language is C++ 3. String Length We are going to find the length of a string input by the user. As we do not know

 Language is C++ 3. String Length We are going to find

Language is C++

3. String Length We are going to find the length of a string input by the user. As we do not know the length beforehand, we will reserve sufficient space beforehand to store the input string. Once the string is input, we can determine its length by checking for the terminating character. The length of a string is the number of characters in it. We will input the string using cin.get() which read all characters until a newline character instead of cin which reads all characters until the first SPACE. For example, the length of the string, Hello world! is 12. Note that this string cannot be input using cin which would only store "Hello" for this input. Function Description Write a function, string length, that takes a string as parameter and returns its length. You will have to look up the usage of cin.get() inline. Input Format For Custom Testing The input is a single line containing a string of length no more than 1000 characters

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!