unit.id should be int/long as I suggest above. If it is string, then you need `unit.id = std::string(entry.d_name + 1)`;