need help with a C++ code for class?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mmaria21
    New Member
    • Feb 2010
    • 5

    need help with a C++ code for class?

    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;


    }
  • lzndcb
    New Member
    • Feb 2010
    • 3

    #2
    <completely solution removed>

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Define two int variables for the x and 0 counts. Then examine each string element to be and x or a 0 and increment the appropriate count variable. After you have processed the entire string, just display the two counts.

      Comment

      • mmaria21
        New Member
        • Feb 2010
        • 5

        #4
        thank you ! that really relped..

        Comment

        Working...