title: How do I use putchar to "squeeze" characters (Ansi-C)
body: <p>i was wondering if i could get some help for my code. I put some partial code below</p>
  
  <pre><code>/*reads char by char til EOF*/
  while((c = getchar()) != EOF)
  {
  
      if(c == '\t')
      {
          putchar(' ');
      }
      else if(c == ' ')
      {
          putchar('d');
      }
      else
      {
          putchar(c);
      }
  }
  </code></pre>
  
  <p>What I am trying to do right now is squeeze space characters entered by the user. So if the user puts in:</p>
  
  <p>a[SPACE][SPACE][SPACE][SPACE][SPACE][SPACE][SPACE][SPACE]a</p>
  
  <p>The output should be just</p>
  
  <p>a[SPACE]a</p>
  
  <p>Right now i have it set up that it replaces all spaces for d's for testing purposes. How would I change my code so that it just prints out 1 space instead of all the spaces the user puts in.</p>
  
  <p>Thanks for any help in advance.</p>