changing the delimiter for cin (c++)
It is possible to change the inter-word delimiter for cin or any other std::istream, using std::ios_base::imbue to add a custom ctype facet. If you are reading a file in the style of /etc/passwd, the following program will read each :-delimited word separately. #include <locale> #include <iostream> struct colon_is_space : std::ctype<char> { colon_is_space() : std::ctype<char>(get_table()) {} … Read more