title: Increment Array
body: <p>I'm trying to increment an array (<code>alphabet[0]</code>) index whenever the letter <code>'a'</code> appears in the user input, however when I print out <code>alphabet[0]</code> I received the wrong output.</p>
  
  <p>Example problem:</p>
  
  <pre><code>"Enter a string" 
  
  adam //input 
  
  2665453 //printed on screen
  2665453
  2665453
  2665453
  2665453
  </code></pre>
  
  <p>The output  I'm attempting to achieve should be the number 2, for the 2 'a's in adam.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>class Counter {
  
      public:
          string input; //the string used for user input
          int alphabet[26];
          int numbers[10];
      void countcharacters();
      void countnumbers();
  
      private:
  };
  
  void Counter::countcharacters() {
      cout &lt;&lt; "Enter a string" &lt;&lt;endl;
      getline(cin, input);
  
      for(int i=0; i&lt;input.length(); i++) {
          if(input.at(i) == 'a'){
              alphabet[0]++;
          }
      cout &lt;&lt; alphabet[0] &lt;&lt; endl;
      }
  }
  </code></pre>