title: Using C++ how many characters are in a string array?
body: <p>I have the below piece of code and I'm very confused by it. I'm trying to figure out how much memory (bytes of memory/space is actually being taken up by my partially filled array). I've got the below piece of code but I'm a bit confused. <br></p>
  
  <p>If I declare a string array of 8 elements, and partially fill the elements with the two strings. The for loop will start at 0 and go until size of my array 32 possible bytes (assuming I need 4 bytes per string) divided by size of the first element in the array. That is returns 4 - the size of the element of the first string in the array. But that still doesn't tell me how many letters/characters are in that string. <br></p>
  
  <p>I understand inside the loop we increment count when the value in the array doesn't equal a blank/null value. Giving us the total filled (non empty) positions in our array. However I still don't have a value for our actual amount of characters.  <br></p>
  
  <p>How does this tell us how many characters are in my strings? </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  int main() 
  {
  string test_array[8] = {"henry", "henry2"};
  size_t count = 0;
  
  for (size_t i = 0; i &lt; sizeof(test_array)/sizeof(*test_array); i++) 
  {
  
      cout &lt;&lt; "NOT THE POINTER: "&lt;&lt;sizeof(test_array) &lt;&lt; endl;
      cout &lt;&lt; "POINTER: "&lt;&lt;sizeof(*test_array) &lt;&lt; endl;
  
      if(test_array[i] != "")
          count ++;
  }
  
  int num_elem = sizeof(test_array)/sizeof(test_array[0]);
  cout &lt;&lt; num_elem &lt;&lt; endl;
  cout &lt;&lt; count &lt;&lt; endl;
  
  return 0;
  }
  </code></pre>