Using an iterator to output a string : string iterator « string « C++ Tutorial






#include <iostream>
using std::cout;
using std::endl;

#include <string>
using std::string;

int main()
{
   string string1( "Testing iterators" );
   string::const_iterator iterator1 = string1.begin();

   cout << "string1 = " << string1
      << "\n(Using iterator iterator1) string1 is: ";

   while ( iterator1 != string1.end() ) 
   {
      cout << *iterator1; 
      iterator1++;        
   }

   cout << endl;
   return 0;
}
string1 = Testing iterators
(Using iterator iterator1) string1 is: Testing iterators








15.14.string iterator
15.14.1.Using an iterator to output a string
15.14.2.use iterator
15.14.3.string::npos