Understanding Shared Memory Using C
问题 Using C, I'm trying to set up shared memory. My code looks like: key_t key = ftok("SomeString", 1); static int *sharedval; int shmid = shmget(key, sizeof(int), S_IRUSR | S_IWUSR); // less permissions sharedval = (int *) shmat(shmid, NULL, 0); *sharedval = 0; However the second I run that last line, I get a segmentation fault. When debugging, I can print "sharedval" and I get a memory address, presumably the place in memory I got. So I would assume all I have to do is use *sharedval to assess