I have a file that is outputting information into a class. Specifically one of the strings I am trying to output will go into a vector. The problem is that I am trying to take a string (in this case of interests) which would be formatted:
interest_string = "food, exercise, stuff"
So basically I want to turn the string above into a string of arrays or somehow copy the above string to a vector in each individual string separated by the comma delimeter.
void Client::readClients() {
string line;
while (getline( this->clients, line ))
{
string interest_num_string, interest_string;
istringstream clients( line );
getline( clients, this->sex, ' ' );
getline( clients, this->name, ',' );
getline( clients, this->phone, ' ' );
getline( clients, interest_num_string, ' ' );
getline( clients, interest_string, '.' );
this->interests = atoi(interest_num_string.c_str());
cout << this->sex << "\n" << this->name << "\n" << this->phone << "\n" << interest_num_string << "\n" << interest_string;
}
this->clients.close();
}
istringstream