title: Cleaner way to remove a substring from str in C
body: <p>I have the following string <code>ID is a sample string remove to /0.10</code>, I would like to end up with the following: <code>ID/0.10</code>.</p>
  
  <p>This is what I came up with. However, I'm looking for a cleaner/nicer way of doing this.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main ()
  {
      char str[] = "ID is a sample string remove to /0.10";
      char *a = strstr(str, "ID");
      char *b = strrchr (str, '/');
      if (a == NULL)
          return 0;
      if (b == NULL)
          return 0;
  
      int p1 = a-str+2;
      int p2 = b-str;
      int remL = p2 - p1;
      int until = (strlen(str) - p1 - remL) +1;
  
      memmove (str+p1, str+(p1+remL), until);
      printf ("%s\n",str);
      return 0;
  }
  </code></pre>