Search code examples
cdivisionforwardslash

What does this forward slash do


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


Solution

  • / 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).