title: How to get the real and total length of char * (char array)?
body: <p>For a <code>char []</code>, I can easily get its length by:</p>
  
  <pre><code>char a[] = "aaaaa";
  int length = sizeof(a)/sizeof(char); // length=6
  </code></pre>
  
  <p>However, I cannot do like this to get the length of a <code>char *</code> by:</p>
  
  <pre><code>char *a = new char[10];
  int length = sizeof(a)/sizeof(char);
  </code></pre>
  
  <p>because, I know, <code>a</code> here is a pointer, such that <code>length</code> here will be always be <code>4</code> (or something other in different systems).</p>
  
  <p>My question is that how can I get the length of a <code>char *</code> afterwards? <em>I know someone may challenge me that you already know its <code>10</code> because you just created it. I want to know this because this step of getting its length may come long long way from its creation and I don't want to come long long way back to check this number. Moreover, I also want to know its real length.</em></p>
  
  <p>To be more specific</p>
  
  <ul>
  <li>how can I get its real <code>length=5</code>?</li>
  <li>how can I get its total <code>length=10</code>?</li>
  </ul>
  
  <p>for the following example:</p>
  
  <pre><code>char *a = new char[10]; 
  strcpy(a, "hello");
  </code></pre>