title: Is there anything wrong with sizeof(array)/sizeof(array[0])?
body: <p>One of my colleagues has recently said that the above statement is not type safe and I should use something else as you need as much type safe structures as possible to reduce the amount of possible bugs. </p>
  
  <p>Whilst I agree on being type safe, I'm a little confused as this is the type of code in question (only the contents and length of data[] is modified) </p>
  
  <pre><code>unsigned char data[] = {1,2,3,4,5};
  int data_len = sizeof(data) / sizeof(data[0]); 
  </code></pre>
  
  <p>Where is the part that is not type safe? </p>
  
  <p>Needless to say, other than the comment, the colleague will not explain further. </p>
  
  <p>PS: This is used to copy initialisation data into a class from the constructor, no C++11 compiler exists here, so we can't use std::array or other fancy array initialisation. techniques. </p>