If I would want to operate on pointers which point to one byte should I use void* or char*, because I heard that
sizeof(char)
isn’t always 1 byte, and what about void*? If I do
void *p
++p
will it point everywhere one byte further?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In C pointer arithmetic is not defined for void pointers. Pointer arithmetic is intrinsically tied to the size of the pointed type. And for
void *the size of the pointed type is unknown.To see how pointer arithmetic works for different objects, try this:
However, if the compiler does support it, pointer arithmetic on void pointers works the same as on char pointers.