title: Initializing a char array in C. Which way is better?
body: <p>The following are the two ways of initializing a char array:</p>
  
  <pre><code>char charArray1[] = "foo";
  char charArray2[] = {'f','o','o','\0'};
  </code></pre>
  
  <p>If both are equivalent, one would expect everyone to use the first option above (since it requires fewer key strokes). But I've seen code where the author takes the pain to always use the second method.  </p>
  
  <p>My guess is that in the first case the string "foo" is stored in the data segment and copied into the array at runtime, whereas in the second case the characters are stored in the code segment and copied into the array at runtime. And for some reason, the author is allergic to having anything in the data segment.  </p>
  
  <p>Edit: Assume the arrays are declared local to a function.</p>
  
  <p>Questions: Is my reasoning correct? Which is your preferred style and why?</p>