title: Expand Tabs to Spaces in C?
body: <p>I need to expand tabs in an input line, so that they are spaces (with a width of 8 columns).  I tried it with a previous code I had replacing the last space in every line greater than 10 characters with a '\n' to make a new line.  Is there an way in C to make tabs 8 spaces in order to expand them?  I mean I am sure it is simple, I just can't seem to get it.  </p>
  
  <p>Here's my code:</p>
  
  <pre><code>int v = 0;
  int w = 0;
  int tab;
  extern char line[];
  
  while (v &lt; length) {
  
     if(line[v] == '\t')
        tab = v;
  
     if (w == MAXCHARS) {
        // THIS IS WHERE I GET STUCK
        line[tab] = ' ';
        // set y to 0, so loop starts over
        w = 0;
     }
     ++v;
     ++w;
  }
  </code></pre>