title: Comparing character arrays with an == operator in C
body: <p>I know that the correct way to compare "strings" in C is by using <code>strcmp</code>, but now I tried comparing some character arrays with the <code>==</code> operator, and got some strange results.</p>
  
  <p>Take a look at the following code:</p>
  
  <pre><code>int main()
  {
      char *s1 = "Andreas";
      char *s2 = "Andreas";
  
      char s3[] = "Andreas";
      char s4[] = "Andreas";
  
      char *s5 = "Hello";
  
      printf("%d\n", s1 == s2); //1
      printf("%d\n", s3 == s4); //0
      printf("%d\n", s1 == s5); //0
  }
  </code></pre>
  
  <p><strike>The first <code>printf</code> correctly prints a <code>1</code>, which signals that they are not equal.  But can someone explain to me why, when comparing the character arrays, the <code>==</code> is returning a <code>0</code> ?</strike></p>
  
  <p>Can someone please explain to me why the first <code>printf</code> is returning a <code>1</code> (ie, they are equal) and the character arrays are returning a <code>0</code> ?</p>