Pointer arithmetics with two different buffers

To add the standard quote: expr.add#5 When two pointer expressions P and Q are subtracted, the type of the result is an implementation-defined signed integral type; this type shall be the same type that is defined as std::ptrdiff_­t in the <cstddef> header ([support.types]). (5.1) If P and Q both evaluate to null pointer values, the … Read more

Does the C standard permit assigning an arbitrary value to a pointer and incrementing it?

The assignment: void *ptr = (char *)0x01; Is implementation defined behavior because it is converting an integer to a pointer. This is detailed in section 6.3.2.3 of the C standard regarding Pointers: 5 An integer may be converted to any pointer type. Except as previously specified, the result is implementation-defined, might not be correctly aligned, … Read more

Pointer Arithmetic [closed]

Here is where I learned pointers: http://www.cplusplus.com/doc/tutorial/pointers.html Once you understand pointers, pointer arithmetic is easy. The only difference between it and regular arithmetic is that the number you are adding to the pointer will be multiplied by the size of the type that the pointer is pointing to. For example, if you have a pointer … Read more