string word = "abcde";
  int count = 0;
  for(int i = 0; i < word.length(); i++){
    for(int j = 1; j < word.length(); j++){
      if(word.at(i) == word.at(j)){
        count++;
      } 
    }
  }

i am trying to write a program that when i am given a string i can count letter pairs in the string so for example: cat returns 0 and doggy returns 1. this i what i have written now and i tried cout the loops and such but im still very lost in what i am doing wrong. any help would be very helpful

the count should equal 0 but instead it counts to 4...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.