I have the following code
int main()
{
int a=6;
void *p;
p=&a;
p++;
}
Does the void pointer here increment by a particular value (if it is holding the address of any data type) ?
In the above case p
increments by 1 even though it is pointing to an integer value. According to me the above code invokes Implementation Defined
behavior.
The code in not valid from standard C point of view. It is illegal to increment void *
pointers, or any other pointers to incomplete types.
Your compiler implements it as an extension, which is, of course, non-portable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With