terators provide the ability to access the individual characters in a string.
-
This will print the integer position in the string followed by the letter for all characters in the alphabet.01#include <iostream>02#include <string>03usingnamespacestd;0405intmain()06{07string alphabetLC="abcdefghijklmnopqrstuvwxyz";0809string::const_iterator cii;10intii;1112for(cii=alphabetLC.begin(); cii!=alphabetLC.end(); cii++)13{14cout << ii++ <<" "<< *cii << endl;15}16}0 a 1 b 2 c 3 d 4 e 5 f 6 g 7 h ... ..
Tidak ada komentar:
Posting Komentar