title: How to know the size (in bytes) of a char array passed to a function?
body: <p>I am testing the <strong><em>sizeof</em></strong> operator.
  In two cases in my code, I get the <strong><em>size of the pointer</em></strong> (I think).
  In the other cases I get <strong><em>how many bytes the arrays occupy</em></strong>.
  <em>How can I get the size of the array in bytes when I pass it to a function?</em>
  Isn't the <strong><em>sizeof</em></strong> operator enough?
  Am I doing something wrong?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  /*Testing the operator sizeof*/
  
  void test (char arrayT[]);
  void test2 (char *arrayU);
  
  int main(int argc, char *argv[]){
  
      char array1[7];
      printf("array1 size is:%d\n", sizeof array1);
      /*array1 size is: 7*/
  
      char array2[] = { '1', '2', '3', '4', '5', '6', '7'};
      printf("array2 size is:%d\n", sizeof array2);
      /*array2 size is: 7*/
  
      char array3[] = "123456";
      printf("array3 size is:%d\n", sizeof array3);
      /*array3 size is: 7*/
  
      unsigned char array4[] = "123456";
      printf("array4 size is:%d\n", sizeof array4);
      /*array4 size is: 7*/
  
      char arrayX[] = "123456";
      test(arrayX);
      /*arrayT size is: 4*/
  
      char arrayY[] = "123456";
      test2(&amp;arrayY[0]);
      /*arrayU size is: 4*/
  
      return 0;
  }
  
  void test (char arrayT[]){
      printf("arrayT size is:%d\n", sizeof arrayT);
  }
  
  void test2 (char *arrayU){
      printf("arrayU size is:%d\n", sizeof arrayU);
  }
  </code></pre>