Check out example codes for "iterate over string c++". It will help you in understanding the concepts better.

Code Example 1

// C++11
for(char& c : str) {
    do_things_with(c);
}

Code Example 2

void print(const std::string &s)
{
    for (std::string::size_type i = 0; i < s.size(); i++) {
        std::cout << s[i] << ' ';
    }
}

Learn ReactJs, React Native from akashmittal.com