What is wrong in this code is C++? how to count letters in a word.
Hello I am doing this class in udemy and I did this code from the video exactly I dont know what is wrong. #include <iostream> #include <string> using namespace std; int main() { string word = ""; do { cout << "Enter a word that has at least 5 characters:"<< endl; cin>> word; }while(word.size() < 5); char searchCh = '0'; cout <<"Enter the character and the program will tell you how many times it appears in the word"<< word<<"."<<endl; cin>> searchCh; int counter= 0; for(int i = 0; i< (int)word.size(); i++) { char ch =word.at(i); //if the character maches the chrachter we are lookingfor if(searchCh == ch) { counter++; //counter==counter+1 }//increment a couner } cout<<"The number of" <<searchCH<<"'S is the word"<< word<<"is"<<counter<<endl; }