Jumat, 14 Desember 2012

ANSI C++ string class iterators:

terators provide the ability to access the individual characters in a string.
01#include <iostream>
02#include <string>
03using namespace std;
04    
05int main()
06{
07   string alphabetLC="abcdefghijklmnopqrstuvwxyz";
08 
09   string::const_iterator cii;
10   int ii;
11 
12   for(cii=alphabetLC.begin(); cii!=alphabetLC.end(); cii++)
13   {
14      cout << ii++ << " " << *cii << endl;
15   }
16}
This will print the integer position in the string followed by the letter for all characters in the alphabet.
0 a
1 b
2 c
3 d
4 e
5 f
6 g
7 h
...
..


Tidak ada komentar:

Posting Komentar