Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#include <iostream>
#include <string>
using namespace std;
int main(){
int count = 0;
char input;
string word;
cout<<"Enter a Word: ";
cin>>word;
cout<<"Enter a Character That You Want to Count: ";
cin>>input;
for(int i = 0; i < word.size(); i++){
if (word.at(i) == input){
count++;
}
}
cout<<count<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment