title: 2 ways of accessing value of an array of pointers in C
body: <p>The first block</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  const int MAX = 3;
  
  int main() {
  
      int  var[] = { 10, 100, 200 };
      int i, *ptr[MAX];
  
      for (i = 0; i &lt; MAX; i++) {
          ptr[i] = &amp;var[i]; /* assign the address of integer. */
      }
  
      for (i = 0; i &lt; MAX; i++) {
          printf("Value of var[%d] = %d\n", i, *ptr[i]);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>Easy to understand, since ptr is an array of int pointers. So when you need to access the <code>i</code>-th element, you need to dereference its value as <code>*ptr[i]</code>.</p>
  
  <p>Now the second block, just the same, but now it points to an array of <code>char</code> pointer:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  const int MAX = 4;
  
  int main() {
  
      char *names[] = {
          "Zara Ali",
          "Hina Ali",
          "Nuha Ali",
          "Sara Ali",
      };
  
      int i = 0;
  
      for (i = 0; i &lt; MAX; i++) {
          printf("Value of names[%d] = %s\n", i, names[i]);
      }
  
      return 0;
  }
  </code></pre>
  
  <p>This time, when we need to access its element, why don't we add a <code>*</code> first?</p>
  
  <p>I tried to form a correct statement to print this value, seems if you dereference, it will be a single char. Why?</p>
  
  <pre><code>printf("%c", *names[1]) // Z
  </code></pre>
  
  <p>I know there is no strings in C, and it is a <code>char</code> array. And I know pointers, but still don't under the syntax here.</p>