title: Replacing three 'a' in with a single '*' in a string
body: <p>So my program should get input from an user and store it in an array. After that if the input string includes three 'a's in a row it should be replaced with a single '*'. However I can't seem to get it right. It only replaces the first a with a *. I tried to replace the following 2 a with a blank but the output looks funny. 
  For this exercise I have to use <code>putchar()</code> and <code>getchar(</code>).</p>
  
  <p>Thank you in advance.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  char c;
  char buffer[256];
  int counter= 0;
  int i;
  
  int main()
  {
      while ((c = getchar()) != '\n') {
  
          buffer[counter] =c;
          counter++;
  
          if (counter &gt;255) {
              break;
          }
      }
  
      for(i=0; i&lt;256; i++) {
  
          if(buffer[i]== 'a'&amp;&amp;buffer[i+1]=='a'&amp;&amp;buffer[i+2]=='a')
          {
  
              buffer[i]= '*';
              buffer[i+1]=' ';
              buffer[i+2]=' ';
  
          }
          putchar(buffer[i]);
      }
  
      putchar('\n');
      return 0;
  }
  </code></pre>