help with returning double letters

I'm stuck on this problem and have no idea how to solve this and need help.
"Write a function called NumDouble that takes a string S as an argument
and returns the number of times there is a double-letter inside it.

For example if S=“happy” then the function returns 1.
If S=”balloon” or S=”Zaxxxon” the function returns 2.
If S=”Lollapallooza” the function returns 3… etc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
int NumDouble (string S) {
      int nd = 0; 
}

int main() {

            cout << “Enter a string: “;
            string q;
            cin >> q;
            int x;
            x = NumDouble(q);
            cout << “Number of doubles in “ << q << “ is “ << x << endl;
            system(“pause”);
}
Topic archived. No new replies allowed.