use iterator : string iterator « String « C++






use iterator

  
 


#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
  string str1("Strings handling is easy in C++");
  string::iterator p;
  unsigned int i;

  // use iterator
  p = str1.begin();
  while(p != str1.end()) 
    cout << *p++;
  cout << endl;


  return 0;
}

/* 
Strings handling is easy in C++

 */        
    
  








Related examples in the same category

1.Using an iterator to output a string
2.string::npos
3.Create an iterator to a string and Use it to cycle through the characters of a string
4.increment the iterator
5.Access the contents of a string using iterators