Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: wordsmithing

C library functions that make changes to arrays or objects usually take at least two arguments: a pointer to the array or object and an integer indicating the number of elements or bytes to be manipulated. If the improper arguments are supplied improperly during to such a function call, it might cause the function to form a pointer that does not point into or just past the end of the object, resulting in undefined behavior.

...

the element count of the pointer p is sizeof(arr) / sizeof(arr[0]), that is, 5.  The element count of the pointer p2, is sizeof(arr), that is, 20 (on platforms where sizeof(int) == 4).  The element count of the pointer p3 is 12 (on  on platforms where sizeof(int) == 4), because p3 points two elements past the start of the array arr.  The element count of p4 is treated as though it were unsigned char * instead of void *, and so is the same as p2.

...