-3
for (n=0;n<sizeof(arr)/sizeof(*arr); n++)

i got this piece of code and don't know what this '/' does.

is it just a arithmetic operater and means 'divide by' ?

'arr' is my array, so does it just divide the size of my array by the size of the array itself?

I'm confused

wasido
  • 74
  • 6
  • There is a difference between `sizeof(arr)` (the size of the entire array) and `sizeof(*arr)` (the size of an array element). –  Nov 02 '15 at 23:04

1 Answers1

3

/ is the division operator and sizeof arr / sizeof *arr is the idiomatic way to get the number of elements of an array (number of bytes of the array / number of bytes of the first element of the array).

ouah
  • 142,963
  • 15
  • 272
  • 331