arrays with double letters

Hello everyone . Can you help me with this :

Write a full program (starting from #include) ) that is supposed to get an input sentence from the user and write a function that counts the number of character doubles in a phrase entered by the user. The output should look like the example below.

Enter sentence: Hobbits love cookies!! There are 3 character doubles.

You do not have to worry about detecting upper vs. lower-case letters, nor do you have to handle the case when a character occurs three times or more in a row.
Set the count to zero.
Examine each character in turn, starting with the second letter.
If character is the same as the previous one, add one to the count.

Which of these can you not do?
i can do only the 1 one :( please can you help me . Can you write it in c++
We won't do your homework for you. Show us the code you have and where the problem is.
okey man . Than help me just with this how to turn this to code ?

how can i examine each charachter in turn ?
Read in the word into an std::string. Strings allow accessing by index. For two letters to be subsequent, their indeces have to be 1 apart. Thus, by comparing myString[i] to myString[i+1] for all necessary values of i, you can determine if there are "doubles".
Topic archived. No new replies allowed.