C++ version of 'char count'