Вы выполняете это путем приведения и последующего присвоения.
int f(void * p) {
int * i;
i = (int *)p;
//lots of code here with the i pointer, and every line
//really thinks that it is an int pointer and will treat it as such
}
РЕДАКТИРОВАТЬ Из другого связанного с вами вопроса:
typedef struct {
unsigned char a;
unsigned char b;
unsigned char c;
} type_a;
typedef struct {
unsigned char e;
unsigned char f[2];
} type_b;
//initialize type a
type_a sample;
sample.a = 1;
sample.b = 2;
sample.c = 3;
Теперь sample
инициализирован,но вы хотите получить доступ к по-другому, вы хотите притвориться , что на самом деле эта переменная имеет другой тип, поэтому вы объявляете указатель на тип, который хотите "замаскировать" sample
как:
type_b * not_really_b;
not_really_b = (type_b*)&sample;
Видите, в этом вся магия.
not_really_b->e
равно 1
not_really_b->f[0]
равно 2
not_really_b->f[1]
равно 3
Это ответ на ваш вопрос?