#include #include #include #include #include #include #include struct comma_ws : std::ctype { static const mask* make_table() { static std::vector v(classic_table(), classic_table() + table_size); v[','] |= space; // comma will be classified as whitespace return &v[0]; } comma_ws(std::size_t refs = 0) : ctype(make_table(), false, refs) {} }; int main() { std::string s = "Hello,How,Are,You,Today"; std::istringstream buf(s); buf.imbue(std::locale(buf.getloc(), new comma_ws)); std::istream_iterator beg(buf), end; std::vector v(beg, end); copy(v.begin(), v.end(), std::ostream_iterator(std::cout, ".")); std::cout << '\n'; }