+ 1
How to get the first element in an string array c++?
I'm used to work with string array like this: Std::string names[] = { "john", "martinez"}; I don't have any problem to get the name 'jhon', but I don't know hot to obtain 'john' when the array is like this: Std::string names[] = { "john martinez", 'rick Morty"}; When I want to access to the first element, it gets "john Martinez" and not only "John", how can I get only "John" without Martinez?
2 Respuestas
+ 4
Anything between those "quotation marks" becomes the element spaces included.
+ 2
here u are:
https://code.sololearn.com/cLB0baXMLGv7/#cpp
std::string::find ref:
https://en.cppreference.com/w/cpp/string/basic_string/find
std::string::substr ref:
https://en.cppreference.com/w/cpp/string/basic_string/substr