When a pointer to a particular type (say int
, char
, float
, ..) is incremented, its value is increased by the size of that data type. If a void
pointer which points to data of size x
is incremented, how does it get to point x
bytes ahead? How does the compiler know to add x
to value of the pointer?
相关问题
- Multiple sockets for clients to connect to
- Do the Java Integer and Double objects have unnece
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- Index of single bit in long integer (in C) [duplic
The C standard does not allow void pointer arithmetic. However, GNU C is allowed by considering the size of void is
1
.C11 standard §6.2.5
Paragraph - 19
Following program working fine in GCC compiler.
May be other compilers generate an error.
Pointer arithmetic is not allowed on
void*
pointers.