I have a loop that does the following:

```
short fooID;
char line[256]
map<short,foo> foos;
set<short> barIDs;
while (fgets(line,256,file) != NULL){
  string line_copy = line;
  /*use token to split the line into several parameters which does not effect foo * bar*/
  string token = strtok(line,",");
  token = strtok(NULL,",");
  token = strtok(NULL,",");
  token = strtok(NULL,",");
  token = strtok(NULL,",");
  barID = short(atoi(token));
  foo * bar;
  bar = new foo;
  if(barIDs.find(barID) == barIDs.end()){
     barIDs.insert(barID);
     bar->setID(barID);
     this->foos[barID] = bar;
  }
}

```

When I run this code, I get a segmentation fault when all the bars are loaded from the file.
the barID range is 1-1192. 

Any thoughts?

Thanks

*The code above is only a typed summery of my actual code*