Ivami Ivami - 3 months ago 12
C++ Question

Simple way of returning the length of the string to output

I am writing a program that prints out user entered string and lenght.

I was able to get this part

#include <iostream>
#include <string>
using namespace std;
int main()
{
string x ;
getline (cin, x) ;
cout << "You entered: " << x << "String lenght/size is: "<< <<endl;



}


Rest of the process remains incomprehesible

Answer

There's a function that belongs to the string object, in your case x.length() will return the length of the string.