I come across this code in an assignment. It is a MC question so it may be incorrect. I want to understand it first.
Does the 1st statement mean allocate 3 bytes to a long?
Does 'p += 3' mean incrementing the long *p for 3? Will it have memory of 3 times (size of long)?
malloc() requests a block of memory from the heap, and free() returns it.
It's an error to free() a block of memory that wasn't obtained from malloc() (there are alternatives to malloc() than can be used; like calloc() and realloc()),
Your code gets some memory, increments the pointer by 3 bytes, then calls free() on that new location. This is a serious error.
CORRECTION: @keskiverto is correct: the pointer is incremented by 12 bytes.