+ 1
How can I input string from user in a vector ???
4 Respuestas
+ 5
@Naitomea
I don't think you need a vector of strings here. Why store single characters in an entire string?
I think you should use char instead, and it will work the same.
+ 2
I think I would do it this way:
std::string s = ""; //Your string
std::cin >> s; //Get user input
std::vector<std::string> whatever; //Vector of strings
whatever.push_back(s); //push_back appends the given value s to the end of the vector
+ 1
@Kinshuk
Sure, thats right, I just based it on the opportunity to have multiple user inputs and therefore multiple strings, then a vector of strings would make sense, wouldnt it?
If not, feel free to correct me :)
- 1
شاید