I need to input 3 full names separated by commas
Full Name 1: John, Smith, Flynn
Full Name 2: Walter, Kennedy, Roberts
Full Name 3: Sam, Bass, Clinton
I think here what you want to is a split method for string class, the method should like this:
void SplitName(const string& fullName, const string& delims, vector& names)
{
size_t i = 0;
size_t j = 0;
while (i < fullName.size())
{
i = fullName.find_first_not_of(delims, i);
j = fullName.find_first_of(delims, i);
if (i < fullName.size())
{
names.push_back(fullName.substr(i, j - i));
}
i = j;
}
}
you can define the ":," as delims, then names[1] is First Name, names[2] is Middle Name, names[3] is Last Name.