User Tools

Site Tools


c_-_c_iterator:using_an_iterator_to_output_a_string

C - C++ Iterator - Using an Iterator to Output a String

#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;
}
c_-_c_iterator/using_an_iterator_to_output_a_string.txt · Last modified: 2020/07/15 09:30 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki