title: C iterate through char array with a pointer
body: <p>I am very new in C and was wondering about how to get each element of an array using a pointer. Which is easy if and only if you know the size of the array.
  So let the code be: </p>
  
  <p><code>#include &lt;stdio.h&gt;</code></p>
  
  <pre><code>int main (int argc, string argv[]) {
      char * text = "John Does Nothing";
      char text2[] = "John Does Nothing";
  
      int s_text = sizeof(text); // returns size of pointer. 8 in 64-bit machine
      int s_text2 = sizeof(text2); //returns 18. the seeked size.
  
      printf("first string: %s, size: %d\n second string: %s, size: %d\n", text, s_text, text2, s_text2);
  
      return 0;
  }
  </code></pre>
  
  <p>Now I want to determine the size of <code>text</code>. to do this, I found out, that the String will end with a <code>'\0'</code> character. So I wrote the following function:</p>
  
  <pre class="lang-c prettyprint-override"><code>int getSize (char * s) {
      char * t; // first copy the pointer to not change the original
      int size = 0;
  
      for (t = s; s != '\0'; t++) {
          size++;
      }
  
      return size;
  }
  </code></pre>
  
  <p>This function however does not work as the loop seems to not terminate.</p>
  
  <p>So, is there a way to get the actual size of the <code>char</code>s the pointer points on?</p>