You can use the getline() function. Notice in the link, that there is a parameter called delim which stands for a character that delimits your reading operation (it will stop reading in the string when it finds that character). By default, the delimiter is the newline character (and thus, the name "getline()"). To read, up to a comma, you can do this:
getline(myfile, n.lastname, ','); But, since you can also stop at a colon, you will have to first extract up to the colon, and then extract the individual names from that string. That can be done with a stringstream object. As so, for example:
string str_up_to_colon;
getline(myfile,str_up_to_colon,':');
stringstream ss(str_up_to_colon);
while(!ss.eof()) {
getline(ss, n.lastname, ',');
getline(ss, n.firstname, ',');
v1.push_back(n);
}; This might not work for all the cases that you have, but the examples above give you the basic tool set to use. If all fails, you can always use the myfile.get() function to extract each character one by one and construct your strings one character at a time.