Ivami Ivami - 1 year ago 89
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 Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download