cpp iterate through string code example
Example 1: how to iterate throguh a string in c++
void print(const std::string &s)
{
for (std::string::size_type i = 0; i < s.size(); i++) {
std::cout << s[i] << ' ';
}
}
Example 2: c++ read each char of string
std::string str = ???;
for(std::string::iterator it = str.begin(); it != str.end(); ++it) {
do_things_with(*it);
}