0
string lastNames(string name[],int SIZE){
  stringstream ss;
  for(int i = 0; i < SIZE; i++){
    ss << '"' << name[i].substr(0) << name[i].erase(name[i].find(',')) << '"' << " ";
    
  }  
  return ss.str();
}

this is outputting my list of names correctly other than all the names come out twice like "namename"
how can i stop this?

Edited by Nick Evan: Add code-tags

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Sseeth
0

would't it be easier to use? :

string lastNames(std::list<string> name_list){
  stringstream ss;
  for(std::list<string>::const_iterator i = name_list.begin(); i != name_list.end(); i++){
    ss << '"' << i->substr(0) << i->erase(i->find(',')) << '"' << " ";
    
  }  
  return ss.str();
}

what exactly should come out, i need an example!

Edited by programmersbook: n/a

0

Don't worry about it i got it in the end, thanks though.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.