> void *big_endian;
Maybe because this isn't pointing anywhere.
> vp = vp+3;
Remember, call by value.
This does NOT change the value of the pointer used to call this function.
Also, arithmetic on void pointers is undefined anyway, since you need to know the type in order to figure out how much to advance by. sizeof(void) is meaningless.
The whole pointer arithmetic thing sucks anyway.
How about this?
Code:
#include <stdio.h>
int return_int(void **vp)
{
int num = 0;
unsigned char *p = *vp;
int i;
for(i = 0; i < 4; i++)
{
num = ( num << 8 ) | p[3-i];
}
*vp = p + 4;
return num;
}
int main ( ) {
unsigned char buff[] = {
0x11, 0x22, 0x33, 0x44,
0x55, 0x66, 0x77, 0x88
};
void *p = buff;
printf( "%x\n", return_int(&p) );
printf( "%x\n", return_int(&p) );
}