mardi 2 février 2016

Extracting an int out of void*

I have a method that returns void* and it is basically some block of data from allocated shared memory on linux.

The first 4 bytes in that data are an int and I haven't managed to extract that int.

These are the methods what I have tried:

int getNum(void* data) 
{
    return *(int*)data; // 1
    return *(int*)(data & 0xFFFFFFFF); // 2
} 

Thanks in advance!

Aucun commentaire:

Enregistrer un commentaire