I have some code i've written and i need to splita string and assign the results to 2 variables type and value
The first part of the string up to the : would the type and what is after the : would be the value
When i output the variables i get NAME as the type variable but the value variable is empty. Is this becuase the temp variable has already been erased? If i take out the type erase, the value erase works but it won't do both
Would it be best to split the string on the :
string temp = "NAME: name";
std::size_t pos;
pos= temp.find(":");
if(pos != string::npos)
{
int len = temp.size();
string type= temp.erase(pos, (len-pos));
string value = temp.erase(0, pos+2);
}