I've this code i wrote that sets the array to 0
int arr[4];
memset(arr, 0, sizeof (arr));
Very simple, but how the code works without any errors even though sizeof(arr)
= 16 (4 the array size * 4 for int) and the size i used when i declared the array is 4, How memset
sets 16 bits to zero and the array i passed as a parameter has the size of 4?
I used memset(arr, 0, sizeof(arr)/sizeof(*arr));
to get the real size of the array and the result was accurate and it gives me 4
but how the above code works correctly?