fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <iterator>
  5.  
  6. void f( char c) {
  7. c = c + 1; // do your processing
  8. std::cout << c << std::endl;
  9. }
  10.  
  11. int main()
  12. {
  13. std::string str = "string";
  14. for ( int i = 0; i < str.length(); ++i)
  15. std::cout << str[i] << std::endl;
  16.  
  17. std::copy( str.begin(), str.end(), std::ostream_iterator<char>( std::cout, "\n"));
  18.  
  19. std::for_each( str.begin(), str.end(), f);
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
s
t
r
i
n
g
s
t
r
i
n
g
t
u
s
j
o
h