Use the STL find() algorithm to obtain an iterator to the start of the first 'a'
#include <iostream> #include <string> #include <cctype> #include <algorithm> #include <vector> using namespace std; int main() { string strA("This is a test."); string::iterator itr = find(strA.begin(), strA.end(), 'a'); return 0; }