Often when iterating through a string (or any enumerable object), we are not only interested in the current value, but also the position (index). To accomplish this by using
Since std::distance is only constant time for random-access iterators, I would probably prefer explicit iterator arithmetic.
Also, since we're writing C++ code here, I do believe a more C++ idiomatic solution is preferable over a C-style approach.
string str{"Test string"};
auto begin = str.begin();
for (auto it = str.begin(), end = str.end(); it != end; ++it)
{
cout << it - begin << *it;
}