Range based for loops on null terminated strings
I sort of assumed that range based for loops would support C-style strings void print_C_str(const char* str) { for(char c : str) { cout << c; } } However this is not the case, the standard [stmt.ranged] (6.5.4) says that range-based-for works in one of 3 possibilities: The range is an array The range is a class with a callable begin and end method There is ADL reachable in an associated namespace (plus the std namespace) When I add begin and end functions for const char* in the global namespace I still get errors (from both VS12 and GCC 4.7). Is there a way to get range-based-for loops to work