문제

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