Question 11.24

Why can't I perform arithmetic on a void * pointer?


The compiler doesn't know the size of the pointed-to objects. Before performing arithmetic, convert the pointer either to char * or to the pointer type you're trying to manipulate (but see also question 4.5).

References: ANSI Sec. 3.1.2.5, Sec. 3.3.6
ISO Sec. 6.1.2.5, Sec. 6.3.6
H&S Sec. 7.6.2 p. 204


Read sequentially: prev next up top


This page by Steve Summit // Copyright 1995 // mail feedback