Filtering a character out of a string in C
<p>So below is a function that is supposed to filter out a given character, ch, from string, and put the filtered version in result.  The puts statement at the bottom ends up putting out a string identical to the original string, regardless of the filtered character, and result ends up being empty. </p>

<pre><code>void filter_ch_index(char string[], char result[], char ch) {
    result[0] = NUL ; // placeholder
    int i;
    for(i = 0; i &lt; strlen(string); i++)
    {
        if(string[i] != ch)
        {
          result[i] = string[i];
        }
    }
    puts(result);
}
</code></pre>