Answer to Question #163441 in C++ for Nick

Question #163441

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;

}


1
Expert's answer
2021-02-13T05:03:04-0500
#include <iostream>
#include <string>
using namespace std;

int main() {
  string userInput;
  int stringSize;

  getline(cin, userInput);

  stringSize = userInput.size();

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

  return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment