title: Strip whitespace from a string in-place?
body: <p>I saw this in a "list of interview questions". Got me wondering. </p>
  
  <p>Not limited to whitespace necessarily, of course, easily generalized to "removing some specific character from a string, in-place". </p>
  
  <p>My solution is: </p>
  
  <pre><code>void stripChar(char *str, char c = ' ') {
    int x = 0;
    for (int i=0;i&lt;strlen(str);i++) {
      str[i-x]=str[i];
      if (str[i]==c) x++;
    }
    str[strlen(str)-x] = '\0';
  }
  </code></pre>
  
  <p>I doubt there is one more efficient, but is there a solution that is more elegant? </p>
  
  <p><strong>edit</strong>: totally forgot I left <code>strlen</code> in there, it is most definitely not efficient</p>