Create an iterator to a string and Use it to cycle through the characters of a string : string iterator « String « C++






Create an iterator to a string and Use it to cycle through the characters of a string

  
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <vector>

using namespace std;

int main()
{
  string strA("This is a test.");

  string::iterator itr;

  
  for(itr = strA.begin(); itr != strA.end(); ++itr)
    cout << *itr;

  return 0;
}
  
    
  








Related examples in the same category

1.Using an iterator to output a string
2.use iterator
3.string::npos
4.increment the iterator
5.Access the contents of a string using iterators