Ok, so I have an array of srings

char array[4][20];

//initialized
strcpy(array[0], "PERSON1");
strcpy(array[1], "PERSON2");
...

My question is how would I use shmget, and shmat to turn this array into shared memory? Any help appreciated!

有帮助吗?

解决方案

int segment_id = shmget(IPC_PRIVATE, sizeof(array),0660 | IPC_CREAT);

char** shared = shmat(segment_id,NULL,0);

This is a possible solution.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top