I was searching for a way to find the size of an array in C without using sizeof and I found the following code:
int main ()
{
int arr[100];
printf ("%d\n", (&arr)[1] - arr);
return 0;
}
Can anyone please explain to me how is it working?
sizeof.%dis certainly not strictly conforming and in fact would fail on a fairly normal-looking big-endian implementation with a 32 bitintand a 64 bitptrdiff_t.