Question-   Assign the size of userinput to stringsize. ex: if userinput is "hello", output is:

Solution-

Question- Assign the size of userInput to stringSize. Ex: if userInput is "Hello", output is:
Size of userInput: 5
#include <iostream>
#include <string>
using namespace std;

int main() {
string userInput;
int stringSize;

getline(cin, userInput);

/* Your solution goes here */

cout << "Size of userInput: " << stringSize << endl;

return 0;
}

 

Solution:-

Cpp Program:

#include <iostream>

#include <cstring>

using namespace std;

int main() {

char userInput[10000];

cin.get(userInput,10000);

int stringSize;

stringSize=strlen(userInput);

cout << "Size of userInput: " << stringSize << endl;

return 0;

}

Our Happy Testimonials

They are fast in responding to homework questions. they have the best technical writers. Thanks for helping me with my programming doubts.

studentDyana
5  stars image

I contact to disklib for homework, they help me out, despite there was some technical issue they gone through extra mile for me and provide me good quality work in first priority. 100% recommended.

studying on laptopAsif Waheed
5  stars image

Desklib's study resources are best & unique. Their study database is easy to access and easy to use.
100 % recommended.

library and studentsMike Taylor
5  stars image