title: why Segmentation fault: 11 occurred for my C code?
body: <p>I tried to write a function that deletes each character in string <code>s1</code> that matches any character in the string <code>s2</code>. 
  Here is the testing code for the squeeze method. </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void squeeze(char s1[], char s2[]);
  
  int main()
  {
      char s1[20] = "HelloWorld", s2[20] = "ol"; 
      squeeze(s1, s2); 
      printf("%s\n", s1); 
      return 0; 
  }
  
  void squeeze(char s1[], char s2[])
  {
      int i, j, k; 
      k = 0; 
      for (i = 0; s1[i] != '\0'; ++i) {
          for (j = 0; s2[j] != '\0'; ++j) {
              if (s1[i] != s2[j])
                  s1[k++] = s1[i];
          }
      }
      s1[k] = '\0';
  }
  </code></pre>
  
  <p>When I run this code, terminal always gives <code>Segmentation fault: 11</code>.
  Could anyone please give me any hints why this happens? </p>