078-voidptr-arith.c (425B)
1 /* void* arithmetic via the GCC byte-arithmetic extension. 2 * 3 * tcc.c relies on `void *p; p + N` being byte-stride pointer 4 * arithmetic. Strict C99 disallows it (no arithmetic on void*); we 5 * follow GCC and tcc-mes. 6 * 7 * Buffer: { 'A', 'B', 'C', 'D', 0 }. void* + 2 + cast to char* + deref 8 * yields 'C' = 67. 9 */ 10 11 char buf[] = "ABCD"; 12 13 int main(void) { 14 void *p = buf; 15 char *q = (char *)(p + 2); 16 return *q; 17 }