title: Reading string in an array in C
body: <p>I'm new to C programming, and I wondered how it worked to read strings in an array. Here is the example that confuses me:</p>
  <pre><code>int main(void) {
      char array[100] = {'a', 'b', 'c', '\0'}; 
      // we add the '\0', so it doesn't read the entire array
  
      array[98] = 'x'; 
      // define that at index [98] there is character 'x'
  
      char *p, *q; 
      // creates pointers
  
      p = array; 
      // pointer p now points toward the address of the array, 
      // which is index [0]
  
      printf(&quot;%s&quot;, p); 
      // Will print everything until a '\0' is reached, 
      // so print 'abc'
  
      printf(&quot;%s&quot;, (p + 2)); 
      // p is now pointing at the address of index[2], 
      // so print 'c'
  
      q = &amp;array[5]; 
      // pass the address of index[5] to q
  
      printf(&quot;%s&quot;, q); 
      // what is printed out?
  }
  </code></pre>
  <p>I thought that the last line <code>printf(&quot;%s&quot;, q);</code> would print everything in the array until it reaches a <code>\0</code> because we specify <code>%s</code> in <code>printf</code>. So, the <code>'x'</code> would be printed, but when I run the program, nothing gets printed. Why is that?</p>
  <p>I get</p>
  <pre><code>abcc
  </code></pre>
  <p>Could you explain me step by step what happens when I read my program? (I'm a newbie)</p>