Hey guys, im just learning c++ and what i have to do for this specific problem is this: Ask the user to enter a string then count and output the number of x's and 0's (zero and not character O) that occur in the string. This is what i have thus far and im kind of stuck. would anyone please help and let me know what im doing wrong? Thank you so much!
#include<iostre am>
#include<string >
using namespace std;
int main()
{
string str;
cout<<"enter a string"<<endl;
cin>>str;
str.size();
for(int i = 0 ; i <str.size();i++ ) {
str[i];
}
cout<<str;
}
#include<iostre am>
#include<string >
using namespace std;
int main()
{
string str;
cout<<"enter a string"<<endl;
cin>>str;
str.size();
for(int i = 0 ; i <str.size();i++ ) {
str[i];
}
cout<<str;
}
Comment