c - Questions about void pointers -
i have 2 questions void pointers; have:
void * foo=malloc(99) void **bar=(void**)malloc(99); int i=1; bar++; *bar = foo; 1.is above equivalent following?
bar[i++] = foo; if yes it's unexpected because bar++; moves double pointer forward , not single pointer, different non void types.
2.why fine return void** void * foo();?
for example:
void * foo(){ void ** bar; return bar; }
1.is above equivalent following?
bar[i++] = foo;if yes it's unexpected because bar++; moves double pointer forward , not single pointer, different non void types.
it's fine because bar pointer array of pointers. size of void* known (it's size of pointer), know next element of void** array is.
2.why fine return
void**void * foo();?
because void* pointer anything. pointer pointer pointer anything, void** can implicitly converted void*.
Comments
Post a Comment