title: How to remove all occurrences of a given character from string in C?
body: <p>I'm attempting to remove a character from a string in C. The problem I am having with my code is that it removes the first instance of the character from the string but also wipes everything after that character in the string too. For example, removing 'l' from 'hello' prints 'he' rather than 'heo'</p>
  
  <pre><code>int i;
  char str1[30] = "Hello", *ptr1, c = 'l';
  ptr1 = str1;
  for (i=0; i&lt;strlen(str1); i++)
  {
      if (*ptr1 == c) *ptr1 = 0;
      printf("%c\n", *ptr1);
      ptr1++;
  }
  </code></pre>
  
  <p>I need to use pointers for this and would like to keep it as simple as possible since I'm a beginner in C.
  Thanks</p>