The interaction between the std::string type and strings that contain a zero byte is a bit fiddly, if you rely on them being more than 1. I'd actually use a vector as an intermediary.
Code:
// untested code follows - written to show idea, not guaranteed correct
char *tempfilter = "All files supported";
std::vector<char> filter(0);
filter.insert(filter.end(), tempfilter, tempfilter + strlen(tempfilter)); // this takes the first '\0' for the ride
for (std::vector<std::string>::const_iterator i = ext.begin(), end = ext.end(); i != end; ++i)
{
if (i->length() > 0)
{
std::string temp = "*.";
temp += *i;
if (i + 1 != end) temp += ';'
filter.insert(filter.end(), temp.begin(), temp.end());
}
}
filter.insert(filter.end(), '\0');
filter.insert(filter.end(), '\0');
std::string filter_to_use(filter.begin(), filter.end());
Note that printing the filter out (std::cout << filter) will only print to the first null character - by convention.