问题
I have a c structure like this :
struc str{
int values[10];
}str
In a posix so like fedora i copied this structure to a part of shared memory (shm_open
, ftruncate
, mmap
and memcpy
) and I got a pointer to structure from shm. Now how do I change a value in the values array by using this pointer (*ptr).
Imagine i want to do str->values[5] = 10; how to I do that using the pointer.
回答1:
Just use the pointer:
struct str *p = ptr;
p->values[5] = 10;
来源:https://stackoverflow.com/questions/8077884/accesing-shm-structure-using-pointer